The Messenger of Allah ﷺ said, "The right of wala belongs only to the one who freed the slave."
أن رسول الله ﷺ قال: إنما الولاء لمن أعتق.
Bukhari narrated it in "The Book of the Mukataba" (2561), and Muslim in "The Book of Emancipation" (1504:6), both of them from Qutayba bin Saeed, who said, "Hisham told us," from Ibn Shihab, from Urwa, that Ayesha informed him, and he mentioned it in a long hadith. See "The Book of Emancipation." As for his saying, "The right of inheritance belongs to the one who frees," it means that if someone frees a slave belonging to him, then that freed slave's inheritance belongs to him if the slave has no other heir, and he is considered his agnatic relative if the slave's heirs do not encompass the whole of his estate.