Jami` at-Tirmidhi, Book 47, Hadith 3328 (In-Book)

Narrated Al-Bara bin 'Azib: "Some people among the Companions of the Prophet died while they had been drinking Khamr. So when it was revealed that it was unlawful, some people among the Companions of the Messenger of Allah said: 'How about our companions who died while they were drinking it?' So (the following) Ayah was revealed: Those who believe and do righteous good deeds, there is no sin on them for what they ate (5:93)."

وَقَدْ رَوَاهُ شُعْبَةُ عَنْ أَبِي إِسْحَاقَ، عَنِ الْبَرَاءِ، أَيْضًا حَدَّثَنَا بِذَلِكَ، مُحَمَّدُ بْنُ بَشَّارٍ بُنْدَارٌ حَدَّثَنَا مُحَمَّدُ بْنُ جَعْفَرٍ، حَدَّثَنَا شُعْبَةُ، عَنْ أَبِي إِسْحَاقَ، بِهَذَا قَالَ قَالَ الْبَرَاءُ بْنُ عَازِبٍ مَاتَ نَاسٌ مِنْ أَصْحَابِ النَّبِيِّ صلى الله عليه وسلم وَهُمْ يَشْرَبُونَ الْخَمْرَ فَلَمَّا نَزَلَ تَحْرِيمُهَا قَالَ نَاسٌ مِنْ أَصْحَابِ النَّبِيِّ صلى الله عليه وسلم فَكَيْفَ بِأَصْحَابِنَا الَّذِينَ مَاتُوا وَهُمْ يَشْرَبُونَهَا فَنَزَلَتْْ ‏:‏ ‏(‏ لَيْسَ عَلَى الَّذِينَ آمَنُوا وَعَمِلُوا الصَّالِحَاتِ ‏)‏ الآيَةَ ‏.‏ قَالَ أَبُو عِيسَى هَذَا حَدِيثٌ حَسَنٌ صَحِيحٌ ‏.‏

sunnah.com