It is narrated from Sayyiduna Thawban (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said: "Whoever follows a funeral and carries (by giving his shoulder to) all four sides of the bier of the deceased, forty of his sins are forgiven in return, and all of them are major sins."
This narration is weak.
Hadith Referenceالمطالب العالية بزوائد المسانيد الثمانية / كتاب الجنائز / 812
Hadith Gradingمحدثین:إسناده ضعيف
Hadith Takhrij«حکم الحدیث المطالب العالیہ محققاً تنسیق د. سعد بن ناصر بن عبد العزيز الشَّثري- مکتبہ شاملہ :قال ابن حجر: ضَعِيفٌ . » «انفرد به المصنف من هذا الطريق»