Very good point, but I suppose "good" and "bad" is a spectrum. The problem is, if a cop with the best intentions knows about bad/illegal behavior of another cop, what are they going to do? If they report them (at least if they're not the bad cop's superior), then the bad cop will still not be punished, but the otherwise good cop will be harassed and hazed until they have no choice but to quit or be fired (or in the case previously mentioned be thrown in a mental institution). So, would it do more "good" in the world to get shoved out the door and not effect change, or to continue doing what you can to bust the criminals that you can? I suppose the answer to that depends on how idealistic you are, but the real world tends not to be boolean.
If they haven't, everyone should see the movie Serpico. Not only is it a good movie made back when Al Pacino actually acted, but it shows the dynamic that an honest cop has to deal with in a corrupt precinct. It is fictional, but it is a good depiction of the options available.