Hi
Over complicating this
In all cases, the referee drops the ball for one player of the team that last touched the ball at the position where it last touched a player, an outside agent or a match official.
In the case where player Team A passes the ball to a team mate and it hits the referee on the way changing possession to Team B the dropped ball gives possession back to Team A where it hit the referee.
If the touch by the referee has little or no impact to play with no change of possession then no need to stop for a DB
Any DB inside the penalty area must be given to the goalkeeper.
Over complicating this
In all cases, the referee drops the ball for one player of the team that last touched the ball at the position where it last touched a player, an outside agent or a match official.
In the case where player Team A passes the ball to a team mate and it hits the referee on the way changing possession to Team B the dropped ball gives possession back to Team A where it hit the referee.
If the touch by the referee has little or no impact to play with no change of possession then no need to stop for a DB
Any DB inside the penalty area must be given to the goalkeeper.