Yes, both refer to the same student. When there is ambiguity about who you mean, and you don't want to use names, you will usually use the same noun to describe that person. Here "the student" verbally harassed his roommate, who is likely also another "student", but to distinguish them you would say "the student" and "the roommate".
The teacher gave a surprise gift to her colleague by placing it in the colleague's desk.
Or you could say "the first student", "the second student" and so on, as in one of my favorite "engineer" jokes.
Two engineering students were walking through the campus. The first student turned to the second student and said "Hey, where did you get that nice bike?"
The second student replied, "Well, you'll never believe it, but I was walking along, minding my own business, when a female student rode up on this bike, threw it down, tore off all her clothes, and shouted, 'Take anything you want from me!'"
The first student nodded. "Yeah, good choice. The clothes probably wouldn't have fit anyway."
Anyway, given this you should be able to get the meaning of the sentence. The author says that "the student" was merely exercising his right to speak his mind, and shouldn't be punished.