The Prophet (ﷺ) said, "Whoever manumits a slave owned by two masters, should manumit him completely (not partially) if he is rich after having its price evaluated."
Sahih al-Bukhari Book 49, Hadith 5