Salama bin Akwa reported,

We set out with the Prophet ﷺ to Khaybar. One of the men said, "Amir, let us hear some of your verses."So Amir began chanting to drive the camels along.The Prophet ﷺ asked, "Who is the driver?"They replied, "Amir."He said, "May Allah have mercy on him."They said, "Messenger of Allah, why not let us enjoy his company longer?"Amir was killed the next morning. The people said, "His deeds have come to nothing. He killed himself."When I returned and found them saying that Amir's deeds had been nullified, I went to the Prophet ﷺ and said, "Prophet of Allah, may my father and mother be ransomed for you, they claim that Amir's deeds have been nullified."He replied, "Whoever said that has lied. He has two rewards. He was one who strove and struggled in Allah's cause. What death could bring him greater reward than this?"

Azami 6834

Sahih

عن سلمة بن الأكوع قال

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

الأعظمي 6834صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Retaliation and crimes
Chapter
Prohibition of protected blood
Section
Whoever killed himself by mistake
Numbering
Jami al-Kamil 6834 (2nd edition)
Azami 6834