Kurayb narrates from Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) that his son died at a place called Qudayd or Usfan. Ibn Abbas (may Allah be pleased with them both) said: O Kurayb! See whether people have gathered. I looked and saw that people had gathered. I informed him, and he asked: Are they forty? I said: Yes. He said: Take the funeral out, for I heard the Messenger of Allah (peace and blessings be upon him) say: "Any Muslim who dies and forty people who do not associate anything with Allah stand over his funeral, Allah will accept their intercession for him."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجمعة / 5621