Abdullah bin Masud reported,

The Messenger of Allah ﷺ led us in a prayer, and we were not sure whether he had added something or left something out. He asked us about it, and we told him what had happened. He then drew his leg back, faced the qiblah, and performed two prostrations, then gave the closing salutation. After that he turned his face toward us and said, "If anything new had occurred regarding the prayer, I would have informed you of it. But I am only a human being. I forget just as you forget. So when I forget, remind me. And whichever of you is uncertain during his prayer, let him strive for what is closest to being correct, complete his prayer on that basis, give the closing salutation, and then perform two prostrations."

Ibn Majah 1211

Sahih

حدثنا محمد بن بشار حدثنا محمد بن جعفر حدثنا شعبة عن منصور قال شعبة كتب إلي وقرأته عليه قال أخبرني إبراهيم عن علقمة

عن عبد الله قال

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

ابن ماجه 1211صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
One who doubts in his prayer and seeks what is correct
Numbering
Darussalam 1211
Ibn Majah 1211