Abu Hurairah and Abu Saeed Khudri reported,

They both heard the Messenger of Allah ﷺ say, "No fatigue, illness, anxiety, sorrow, harm, or distress befalls a Muslim, not even a thorn that pricks him, except that Allah expiates some of his sins by it."

Azami 11934

Sahih

عن أبي سعيد الخدري وأبي هريرة

أنهما سمعا رسول الله ﷺ يقول: ما يصيب المسلم من نصب ولا وصب، ولا هم ولا حزن، ولا أذى ولا غم، حتى الشوكة يشاكها إلا كفر الله بها من خطاياه.

الأعظمي 11934صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Tafsir of the great Quran
Chapter
Virtues of Surah Baqarah
Section
His saying, "Those who, when a calamity befalls them, say, 'Indeed we belong to Allah and indeed to Him we will return.' Those are the ones upon whom are blessings from their Lord and mercy, and it is those who are the guided."
Numbering
Jami al-Kamil 11934 (2nd edition)
Azami 11934