The Messenger of Allah ﷺ said, "Whoever frees his share in a jointly owned slave, if he has wealth that reaches the price of the slave, the slave is to be valued at a fair price, his partners are paid their shares, and the slave becomes fully free at his expense. Otherwise, only the portion he freed is freed."
أن رسول الله ﷺ قال: من أعتق شركا له في عبد، فكان له مال يبلغ ثمن العبد قوم عليه قيمة العدل، فأعطى شركائه حصصهم، وعتق عليه العبد، وإلا فقد عتق منه ما عتق.
Malik narrated it in Manumission and Patronage (1) from Nafi, from Abdullah bin Umar, who said, and then he mentioned it.Bukhari narrated it in Manumission (2522), and Muslim in Manumission (1501:1), both of them by way of Malik, with the same wording.