Sayyiduna al-Sa'ib bin Khallad (may Allah be pleased with him) narrates that the Prophet (peace and blessings be upon him) said: "Whatever hardship afflicts a believer, even a thorn that pricks him, Allah Almighty records a good deed for him because of it, and wipes out a sin of his because of it."
Ahmad recorded it. Its chain contains a narrator, Rishdin, about whom there is criticism.
Hadith Referenceمجمع الزوائد ومنبع الفوائد / كتاب الجنائز / 3792