Given that he reports he disposed of the firearm with New Hampshire police, it would seem that he might not be in trouble based on what the law actually says. In this case we’re talking about 18 USC 922(a)(3) which states that it shall be unlawful:
(3)Â for any person, other than a licensed importer, licensed manufacturer, licensed dealer, or licensed collector to transport into or receive in the State where he resides (or if the person is a corporation or other business entity, the State where it maintains a place of business) any firearm purchased or otherwise obtained by such person outside that State, except that this paragraph (A) shall not preclude any person who lawfully acquires a firearm by bequest or intestate succession in a State other than his State of residence from transporting the firearm into or receiving it in that State, if it is lawful for such person to purchase or possess such firearm in that State, (B) shall not apply to the transportation or receipt of a firearm obtained in conformity with subsection (b)(3) of this section, and (C) shall not apply to the transportation of any firearm acquired in any State prior to the effective date of this chapter;
So it does seem that he’s in the clear if he legally disposed of the firearm in New Hampshire. The question I would have is whether he disposed of it legally. It gets complicated that he’s a Massachusetts resident transferring a gun in New Hampshire, because for that we have 18 USC 922(a)(5):
(5) for any person (other than a licensed importer, licensed manufacturer, licensed dealer, or licensed collector) to transfer, sell, trade, give, transport, or deliver any firearm to any person (other than a licensed importer, licensed manufacturer, licensed dealer, or licensed collector) who the transferor knows or has reasonable cause to believe does not reside in (or if the person is a corporation or other business entity, does not maintain a place of business in) the State in which the transferor resides; except that this paragraph shall not apply to
(A) the transfer, transportation, or delivery of a firearm made to carry out a bequest of a firearm to, or an acquisition by intestate succession of a firearm by, a person who is permitted to acquire or possess a firearm under the laws of the State of his residence, and
(B) the loan or rental of a firearm to any person for temporary use for lawful sporting purposes;
He turned it into the police, but I would note the police are not a federally licensed dealer or collector. Ironically, he would probably have been in the clear completely had he just sold the gun to an FFL the next day at a gun show. For the act of purchasing the firearm, it would appear this student committed no crime, but the act of turning it into the police may have itself been a federal crime, since the police do not hold a federal firearms license, and are not residents of Massachusetts.
But I think that’s being hyper-technical. I doubt you’ll see any prosecution because the kid transferred it to police, even if it violated a technical letter of the law.
UPDATE: As a commenter points out, the definition of “person” in 18USC921 doesn’t include state agencies, like local police, only individuals, and a few other corporate entities. So there was no crime here.