To try and button this up, here's Rule 74:
If in the course of making a substitution, either the player entering
the game or the player retiring plays the puck or who checks or makes
any physical contact with an opposing player while both players
involved in the substitution are on the ice, then the infraction of “too
many men on the ice” will be called.
If in the course of a substitution either the player(s) entering the
play or the player(s) retiring is struck by the puck accidentally, the play
will not be stopped and no penalty will be called.