Al-Adab Al-Mufrad, Book 1, Hadith 38 (English) ⓘ
Abu Hurayra reported that the Messenger of Allah, may Allah bless him and grant him peace, said, "When a person dies, all action is cut off for him with the exception of three things: sadaqa which continues, knowledge which benefits, or a righteous child who makes supplication for him."
حَدَّثَنَا أَبُو الرَّبِيعِ، قَالَ: حَدَّثَنَا إِسْمَاعِيلُ بْنُ جَعْفَرٍ، قَالَ: أَخْبَرَنَا الْعَلاَءُ، عَنْ أَبِيهِ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللهِ صلى الله عليه وسلم قَالَ: إِذَا مَاتَ الْعَبْدُ انْقَطَعَ عَنْهُ عَمَلُهُ إِلاَّ مِنْ ثَلاَثٍ: صَدَقَةٍ جَارِيَةٍ، أَوْ عِلْمٍ يُنْتَفَعُ بِهِ، أَوْ وَلَدٍ صَالِحٍ يَدْعُو لَهُ.
also referenced under: Hadith 38 (Reference) & Book 1, Hadith 38 (In-Book)