"Ata' b. Yasar said that Abu Sa'id al-Khudri reported the Messenger of Allah (ﷺ) as saying:
when one of you is in doubt about his prayer (1:e, how much he has prayed), he should throw away his doubt and base his prayer on what he is sure of. When he is sure about the completion of his prayer, he should make two prostrations (at the end of the prayer). If the prayer is complete, the additional rak'ah and the two prostrations will be supererogatory prayer. If the prayer is incomplete, the additional rak'ahs will compensate it, and the two prostrations will be a disgrace for the devil.
Reference: Sunan Abi Dawud 1024 In-book : Book 2, Hadith 635 English translation : Book 2, Hadith 1019
Help us gift a modern, ad-free Islamic application for the Muslim Ummah. Your donation will be recorded as Sadaqah Jariyah in your book of deeds, In Sha Allah.