It is narrated from Hazrat Khuzaymah bin Thabit (may Allah be pleased with him) that the Noble Prophet (peace and blessings be upon him) said: If a person commits a sin and its prescribed punishment is carried out upon him, then that becomes an expiation for him.
Hadith Referenceمسند احمد / مسند الأنصار رضي الله عنهم / 21876
Hadith Gradingحکم دارالسلام:صحيح لغيره، وهذا إسناد ضعيف لاضطرابه، ولابهام ابن خزيمة فيه