Hadith 1537

He and Abu Sa'id reported the Prophet as saying, “No Muslim is afflicted by difficulty, continuous pain, anxiety, grief, injury, or care, or even by a thorn with which he is pierced, without God thereby making an atonement for his sins.” (Bukhari and Muslim.)

وَعَن أبي هُرَيْرَة وَأبي سَعِيدٍ عَنِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ: «مَا يُصِيبُ الْمُسْلِمَ مِنْ نَصَبٍ وَلَا وَصَبٍ وَلَا هَمٍّ وَلَا حُزْنٍ وَلَا أَذًى وَلَا غَمٍّ حَتَّى الشَّوْكَةُ يُشَاكُهَا إِلَّا كَفَّرَ اللَّهُ بهَا من خطاياه»

Reference: 5615370
In-book reference: Book 5, Hadith 1537