Hakeem bin Hizam reported,

During the days of ignorance, he had freed one hundred slaves and donated one hundred camels for riding. After embracing Islam, he again donated one hundred camels and freed one hundred slaves.He said, "I asked the Messenger of Allah ﷺ, 'Messenger of Allah, what do you say about deeds I used to perform during the days of ignorance, seeking through them to draw near to Allah?'"The Messenger of Allah ﷺ replied, "You have entered Islam with all the good you did before."

Azami 6161

Sahih

عن حكيم بن حزام

أنه أعتق في الجاهلية مائة رقبة، وحمل على مائة بعير فلما أسلم حمل على مائة بعير، وأعتق مائة رقبة. قال: فسألت رسول الله ﷺ، فقلت: يا رسول الله أرأيت أشياء كنت أصنعها في الجاهلية كنت أتحنث بها، يعني أتبرر بها. قال: فقال رسول الله ﷺ: أسلمت على ما سلف لك من خير.

الأعظمي 6161صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Emancipation of slaves
Section
Those who freed slaves in the Jahiliyyah, then accepted Islam
Numbering
Jami al-Kamil 6161 (2nd edition)
Azami 6161