Abu Hurairah reported,

The Messenger of Allah ﷺ led either the noon or afternoon prayer, then gave the closing salutation after only two units and left. Dhul-Shimalayn Ibn Amr said to him, "Has the prayer been shortened, or did you forget?"The Prophet ﷺ asked, "What is Dhul-Yadayn saying?"They replied, "He has spoken the truth, Prophet of Allah."So he completed with them the two units he had left out.

Nasai 1231

Sahih

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

عن أبي هريرة قال

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

النسائي 1231صحيح
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 1231
Nasai 1231