The Messenger of Allah ﷺ said, "The pen has been lifted from three: from the sleeper until he wakes, from the child until he grows up, and from the insane until he regains his reason or recovers."Abu Bakr, in his version of the hadith, added, "And from the afflicted until he is cured."
حدثنا أبو بكر بن أبي شيبة حدثنا يزيد بن هارون ح و حدثنا محمد بن خالد بن خداش ومحمد بن يحيى قالا حدثنا عبد الرحمن بن مهدي حدثنا حماد بن سلمة عن حماد عن إبراهيم عن الأسود
أن رسول الله ﷺ قال رفع القلم عن ثلاثة عن النائم حتى يستيقظ وعن الصغير حتى يكبر وعن المجنون حتى يعقل أو يفيق قال أبو بكر في حديثه وعن المبتلى حتى يبرأ
[Hasan]. Reported by Abu Dawud, Hudud, chapter on the insane person who steals or commits an offense, no. 4398, from the hadith of Hammad bin Salama with this wording. Ibn Hibban, Hakim, and Dhahabi graded it sahih. The narrator from Ibrahim Nakhai is Hammad bin Abu Sulayman.