Fiqh-us-Sunnah Volume 2, Supererogatory Prayer, Fiqh 2.061A.
A person’s imamate is valid even if he leaves out one of the obligatory acts or prerequisites provided the followers complete them and the imam is not aware of the fact that he had left out an obligatory act or prerequisite.
Abu Hurairah reports that the Prophet said: “If the imam leads the prayer correctly, then both you and he will get the reward. If he is mistaken, you will get the reward and he the blame.” This is related by Ahmad and al-Bukhari.
Sahl reports that he heard the Prophet sallallahu alehi wasallam say: “The imam is a warrantor. If he has done well, it is for him and them. If he has done wrong, it is upon him.” This is related by Ibn Majah.
It has been authentically reported from ‘Umar that he led the people in salah while he was sexually defiled and had forgotten that fact. He repeated his salah but those who had prayed behind him did not.