فِيهِ حَدِيثُ عَائِشَةَ رَضِيَ اللَّهُ عَنْهَا حِينَمَا اشْتَرَتْ بَرِيرَةَ لِتُعْتِقَهَا وَاشْتَرَطَ أَهْلُهَا أَنْ يَكُونَ وَلَاؤُهَا لَهُمْ فَقَالَ لَهَا النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ اشْتَرِيهَا فَأَعْتِقِيهَا فَإِنَّمَا الْوَلَاءُ لِمَنْ أَعْتَقَ انظر فتح الربانی: 2/2300
It is the hadith of Sayyida Aisha (may Allah be pleased with her), when she wanted to free Sayyida Barirah (may Allah be pleased with her), but her owners set the condition that the wala’ (right of inheritance/loyalty) would remain with them. But the Noble Prophet (peace and blessings be upon him) said: Buy her and set her free; the wala’ belongs only to the one who sets free.
وَعَنْهُ أَيْضًا أَنَّ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ قَالَ مَنْ بَاعَ عَبْدًا وَلَهُ مَالٌ فَلَهُ مَالُهُ وَعَلَيْهِ دَيْنُهُ إِلَّا أَنْ يَشْتَرِطَ الْمُبْتَاعُ
It is also narrated from Sayyiduna Jabir bin Abdullah, may Allah be pleased with him, that the Messenger of Allah, peace and blessings be upon him, said: Whoever sells a slave and the slave possesses some wealth, then that wealth will belong to the seller, and any debt of the slave will also be the responsibility of the seller, unless the buyer stipulates otherwise.