A man said to the Prophet ﷺ, "My mother passed away suddenly, and I think that if she had been able to speak she would have given charity. Will she receive a reward if I give charity on her behalf?"He replied, "Yes."
حدثنا يحيى قال أخبرنا هشام قال أخبرني أبي قال
أن رجلا قال للنبي ﷺ إن أمي افتلتت نفسها وأظنها لو تكلمت تصدقت فهل لها أجر إن أتصدق عنها قال نعم
Its isnad is sahih. Bukhari narrated it, 3/254, no. 1388, in the chapter on funerals, and Muslim, 2/696, no. 1004, in the chapter on zakat. It has already been mentioned in similar wording. See 16070 and its references.