Sayyiduna Ubadah bin al-Samit (may Allah be pleased with him) relates: I heard the Messenger of Allah (peace and blessings be upon him) say: "Whoever suffers a wound inflicted on his body and gives it in charity (by forgiving it), Allah, the Mighty and Majestic, wipes away his sins equal to the (right) he gave in charity."
Imam Ahmad (may Allah have mercy on him) narrated it from Surayj bin al-Nu'man, from Hushaym, from Mughirah, from Imam al-Sha'bi (may Allah have mercy on him), that Sayyiduna Ubadah (may Allah be pleased with him) said: "I heard."
And Imam al-Nasa'i (may Allah have mercy on him) narrated it from Ali bin Hujr, from Jarir, with a similar meaning.
Related hadith on this topic