Allah, the Exalted, has said:
١٦٢ - باب الصدقة عن الميت والدعاء له
Allah, the Exalted, has said:
And [there is a share for] those who come after them, saying, "Our Lord, forgive us and our brothers who preceded us in faith and put not in our hearts [any] resentment toward those who have believed. Our Lord, indeed You are Kind and Merciful."
On the authority of ʿĀʾishah (may Allah be pleased with her): a man said to the Prophet (peace and blessings be upon him), "My mother passed away suddenly, and I think that, had she been able to speak, she would have given in charity. Will she have a reward if I give in charity on her behalf?" He said, "Yes." Agreed upon (al-Bukhārī and Muslim).
On the authority of Abū Hurayrah (may Allah be pleased with him): the Messenger of Allah (peace and blessings be upon him) said, "When a person dies, his deeds come to an end except for three: an ongoing charity, knowledge from which benefit is derived, or a righteous child who prays for him." Narrated by Muslim.