Hafetz Haim Halachot
Halacha 134 / 215

Hilchos Lashon Hara chapter 10, section 3

This is only allowed if the person telling is better than the wrongdoer. But if he is a sinner like him, and does the same sins, he may not make it public.

Such a person is not trying to help, and is not acting out of fear of Hashem. He really wants to celebrate the other's fall and embarrass him.

About this it says: "I will punish the house of Yehu for the blood of Yizrael" (Hoshea 1:4).

Yehu did a mitzvah when he destroyed the house of Achav in Yizrael. A prophet had told him to do it, and he was rewarded with kingship for four generations. As it says: "Because you did My heart's desire to the house of Achav, sons of the fourth generation will sit of you on the throne of Yisrael" (II Melachim 10:30).

Even so, in the end he was punished, because he himself also had many sins.