Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) said: "When you (mistakenly) stand up, or sit down, or give the salam, then perform the two prostrations of forgetfulness, then recite the tashahhud, then give the salam."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 9333