The Messenger of Allah ﷺ said, "When a person dies, all their deeds come to an end except for three: an ongoing charity, knowledge that benefits others, and a righteous child who prays for them."
أخبرنا علي بن حجر قال حدثنا إسمعيل قال حدثنا العلاء عن أبيه
أن رسول الله ﷺ قال إذا مات الإنسان انقطع عمله إلا من ثلاثة من صدقة جارية وعلم ينتفع به وولد صالح يدعو له
Muslim narrated it in the chapter on wills, the section on the reward that reaches a person after his death, hadith no. 1631, from Ali bin Hajar through the same chain, and it is also in Kubra, hadith no. 6478.Ismail is Ibn Jafar.