Yazid bin Abi Habib (may Allah have mercy on him) said that whenever the Messenger of Allah (peace and blessings be upon him) besieged a fortress and slaves came to him, he (peace and blessings be upon him) would free them; and when their master accepted Islam, he would return the wala to him.
This is munqati' (its chain is broken), and Ibn Lahi'ah is alone in narrating it, and Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الولاء / 21530