The Prophet ﷺ said, "Whoever fasts Ramadan out of faith and seeking reward will have his past sins forgiven, and whoever stands in prayer on Laylat al-Qadr out of faith and seeking reward will have his past sins forgiven."
عن النبي ﷺ قال: من صام رمضان إيمانا واحتسابا غفر له ما تقدم من ذنبه، ومن قام ليلة القدر إيمانا واحتسابا غفر له ما تقدم من ذنبه.
Bukhari narrated it in "The Virtue of Laylat al-Qadr" (2014), and Muslim in "Prayer of the Traveler" (760), both through Abu Salama, from Abu Hurairah, as mentioned.