Hilchos Lashon Hara chapter 10, section 4

We wrote earlier that the fifth condition is that a person’s intent should be for a beneficial purpose. This certainly applies if the people one is speaking to help a robbed, oppressed, injured, or shamed person. Even if the benefit cannot be achieved through one’s telling the story, but one intends to keep people from evil when they hear people denigrating sinners, and the offender himself may repent and emend his deeds when he hears people disparaging him, this too counts as a benefit. For the speaker has no intent to gain enjoyment from the person’s flaws and is jealous for the truth. But if he estimates that there will certainly be no benefit as in a case where the listeners are wicked people who do the same evils and consider them as nothing, one should not relate what happened. Besides there being no benefit, great harm may result if they go and repeat to the perpetrator that one spoke of him, transgressing, You shall not go as a talebearer (Vayikra 19:16). Also, great controversy often results from this. If relating the story can lead to people reporting a Jew to the authorities it is certainly forbidden even if all the conditions are fulfilled.
It makes no difference regarding all this whether the victim of the perpetrator asked one for help or not and whether the victim was a relative. (Many people mistakenly take action against a perpetrator on behalf of a relative even if the facts are not clear, thinking they are fulfilling the mitzvah, Do not hide from your flesh (Yeshayahu 58:7). This is a mistake).