But Locke was one of the few people who understood that Naomi was working for Widdemore and was really there to help kill everyone on the Island. So by killing her he was, in fact, trying to save everyone.
Not 100% true.
So far, only Keamy was intent on killing them.
The rest of Widdemores team dont seem too intent on killing everyone, so to kill Naomi before she has shown one way or another what her intentions were, are not the workings of a totally sane man.