The Prophet ﷺ was praying, and he stood up at the point of the even rakah where he should have sat. He continued his prayer, and at the end of it, before giving the salam, he performed two prostrations, then gave the salam.
أخبرني يحيى بن حبيب بن عربي البصري قال حدثنا حماد بن زيد عن يحيى عن عبد الرحمن الأعرج
أن النبي ﷺ صلى فقام في الشفع الذي كان يريد أن يجلس فيه فمضى في صلاته حتى إذا كان في آخر صلاته سجد سجدتين قبل أن يسلم ثم سلم
Muslim reported it in the Book of Mosques, chapter on forgetfulness in prayer and the sujud for it, hadith 87/570, from the hadith of Hammad bin Zayd. Bukhari reported it in the Book of Forgetfulness, chapter on what has been narrated about forgetfulness when one stands up from the two rakahs of the obligatory prayer, hadith 1225, from the hadith of Yahya bin Saeed Ansari, with the same chain. It is also found in Kubra, hadith 765.