Hakeem bin Hizam reported,

Hakeem bin Hizam said, "Messenger of Allah, what do you think of certain acts of devotion I used to perform in the days of ignorance, such as giving charity, freeing slaves, and maintaining ties of kinship? Will I receive any reward for them?"The Prophet ﷺ replied, "You have embraced Islam along with all the good you previously did."In another narration, Hakeem bin Hizam freed one hundred slaves during the days of ignorance and gave one hundred camels to be ridden in the way of good. Then in Islam he freed another one hundred slaves and gave another one hundred camels. Afterward he came to the Prophet ﷺ and mentioned something similar to the previous account.

Azami 176

Sahih

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

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

الأعظمي 176صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Faith
Chapter
Qualities of faith
Section
One who did good deeds during disbelief then embraced Islam
Numbering
Jami al-Kamil 176 (2nd edition)
Azami 176