The Messenger of Allah ﷺ said, "Whoever frees his share in a slave, the slave is to be valued at a fair price, and the partners are to be given their respective shares from the slave's value, if the one who freed his share has enough wealth to cover the slave's full price. The slave is then fully freed. Otherwise, only the portion that was freed is freed."
حدثنا يحيى بن حكيم حدثنا عثمان بن عمر حدثنا مالك بن أنس عن نافع
قال رسول الله ﷺ من أعتق شركا له في عبد أقيم عليه بقيمة عدل فأعطى شركاءه حصصهم إن كان له من المال ما يبلغ ثمنه وعتق عليه العبد وإلا فقد عتق منه ما عتق
Bukhari narrated it in the Book of Emancipation, chapter "If someone frees a slave jointly owned by two people, or a female slave jointly owned by partners," hadith no. 2522, and Muslim narrated it in the Book of Emancipation, chapter "Whoever frees his share in a slave," hadith no. 1501, from the hadith of Malik with the same wording, and it is found in the Muwatta (Yahya's recension, 772/2).