Sayyiduna Adi bin Hatim (may Allah be pleased with him) said: We said: "O Messenger of Allah, we are not asking you about obedience to one who is God-fearing and acts righteously, but about one who does such and such" (he mentioned evil). He (peace and blessings be upon him) said: "Fear Allah, and listen and obey."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 14312