Sunan al-Darimi 578
حَدَّثَنَا مُوسَى بْنُ إِسْمَاعِيلَ، حَدَّثَنِي إِسْمَاعِيلُ بْنُ جَعْفَرٍ الْمَدَنِيُّ، عَنِ الْعَلَاءِ بْنِ عَبْدِ الرَّحْمَنِ، عَنْ أَبِيهِ، عَنْ أَبِي هُرَيْرَةَ ﵁، عَنِ النَّبِيِّ ﷺ قَالَ: " إِذَا مَاتَ الْإِنْسَانُ، انْقَطَعَ عَمَلُهُ إِلَّا مِنْ ثَلَاثٍ: عِلْمٍ يُنْتَفَعُ بِهِ، أَوْ صَدَقَةٍ تَجْرِي لَهُ، أَوْ وَلَدٍ صَالِحٍ يَدْعُو لَهُ "
Musa ibn Ismaʿil narrated to us; Ismaʿil ibn Jaʿfar al-Madani narrated to me, from al-ʿAlaʾ ibn ʿAbd ar-Rahman, from his father, from Abu Hurayrah, may Allah be pleased with him, from the Prophet ﷺ, who said: "When a person dies, his deeds are cut off except from three: knowledge that is benefited from, or charity that continues for him, or a righteous child who prays for him."