Walking at a Funeral and Prayer over the Dead - Section 1 Mishkat al-Masabih 1646

Arabic hadith text
وَعَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «أَسْرِعُوا بِالْجَنَازَةِ فَإِنْ تَكُ صَالِحَةً فَخَيْرٌ تُقَدِّمُونَهَا إِلَيْهِ وَإِنْ تَكُ سِوَى ذَلِكَ فشر تضعونه عَن رقابك»
Translation

Abu Huraira reported God’s messenger as saying, “Walk quickly at a funeral, for if the dead person was good it is a good condition to which you are sending him on, but if he was otherwise it is an evil of which you are ridding yourselves.” (Bukhari and Muslim.)