Skip to content

Commit c688702

Browse files
passgatmarckleinebudde
authored andcommitted
can: slcan: do not sleep with a spin lock held
We can't call close_candev() with a spin lock held, so release the lock before calling it. After calling close_candev(), we can update the fields of the private `struct can_priv' without having to acquire the lock. Fixes: c4e54b0 ("can: slcan: use CAN network device driver API") Link: https://lore.kernel.org/linux-kernel/Ysrf1Yc5DaRGN1WE@xsang-OptiPlex-9020/ Link: https://lore.kernel.org/all/[email protected] Reported-by: kernel test robot <[email protected]> Signed-off-by: Dario Binacchi <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent cc944c8 commit c688702

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/net/can/slcan/slcan-core.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,15 +688,14 @@ static int slc_close(struct net_device *dev)
688688
clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
689689
}
690690
netif_stop_queue(dev);
691+
sl->rcount = 0;
692+
sl->xleft = 0;
693+
spin_unlock_bh(&sl->lock);
691694
close_candev(dev);
692695
sl->can.state = CAN_STATE_STOPPED;
693696
if (sl->can.bittiming.bitrate == CAN_BITRATE_UNKNOWN)
694697
sl->can.bittiming.bitrate = CAN_BITRATE_UNSET;
695698

696-
sl->rcount = 0;
697-
sl->xleft = 0;
698-
spin_unlock_bh(&sl->lock);
699-
700699
return 0;
701700
}
702701

0 commit comments

Comments
 (0)