Abu Hurairah reported,

The Messenger of Allah ﷺ ended the prayer after two units.Dhul-Yadayn said to him, "Has the prayer been shortened, or did you forget, Messenger of Allah?"The Messenger of Allah ﷺ asked, "Is Dhul-Yadayn telling the truth?"The people answered, "Yes."So the Messenger of Allah ﷺ stood and prayed the remaining two units, then gave the closing salutation. Then he said the takbir and made a prostration like his usual prostration, or longer. Then he raised his head, then prostrated again like his usual prostration, or longer. Then he raised his head.

Nasai 1226

Sahih

أخبرنا محمد بن سلمة قال حدثنا ابن القاسم عن مالك قال حدثني أيوب عن محمد بن سيرين

عن أبي هريرة

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

النسائي 1226صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Forgetfulness
Chapter
What one should do if he gives salaam after two rakahs forgetfully and speaks
Numbering
Darussalam 1226
Nasai 1226