The Messenger of Allah ﷺ said, "Whoever performs the funeral prayer over a deceased person in the mosque, there is nothing against him."
حدثنا مسدد حدثنا يحيى عن ابن أبي ذئب حدثني صالح مولى التوأمة
قال رسول الله ﷺ من صلى على جنازة في المسجد فلا شيء عليه
[Its isnad is hasan]. Ibn Majah related it in the Book of Funerals, chapter on what has been mentioned about the funeral prayer in the masjid, hadith no. 1517, from the hadith of Muhammad bin Abdul-Rahman bin Abu Dhib, through this same chain.Salih narrated it before his memory became confused. And his statement, "then there is nothing against him," the correct wording is, "then there is nothing for him," meaning no special reward, as Sindi explained it.