Locked posts do not have upvote, downvote or flag buttons. Thus the UI clearly communicates that you cannot do these actions.
However, the upvote and flag buttons are still shown on comments, giving the impression that you can still upvote or flag them.
...but you can't.
Why not just remove the buttons, instead of popping up a big ugly message after they have already been clicked? This would improve the UX in my opinion.