summaryrefslogtreecommitdiff
path: root/drivers/net/can/slcan/slcan-core.c
diff options
context:
space:
mode:
authorDario Binacchi <dario.binacchi@amarulasolutions.com>2022-07-15 09:29:51 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2022-07-19 20:54:53 +0200
commitc6887023268e8c92c7409613065db7ba50b25f18 (patch)
treef92a57c38ca01ccce0379f399dd33e362bf38e05 /drivers/net/can/slcan/slcan-core.c
parentcc944c89c53eee81b266aed2cb1f445488e54e6a (diff)
downloadlwn-c6887023268e8c92c7409613065db7ba50b25f18.tar.gz
lwn-c6887023268e8c92c7409613065db7ba50b25f18.zip
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: c4e54b063f42f ("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/20220715072951.859586-1-dario.binacchi@amarulasolutions.com Reported-by: kernel test robot <oliver.sang@intel.com> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/slcan/slcan-core.c')
-rw-r--r--drivers/net/can/slcan/slcan-core.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c
index d9bf75a25988..057b211f3e7f 100644
--- a/drivers/net/can/slcan/slcan-core.c
+++ b/drivers/net/can/slcan/slcan-core.c
@@ -688,15 +688,14 @@ static int slc_close(struct net_device *dev)
clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
}
netif_stop_queue(dev);
+ sl->rcount = 0;
+ sl->xleft = 0;
+ spin_unlock_bh(&sl->lock);
close_candev(dev);
sl->can.state = CAN_STATE_STOPPED;
if (sl->can.bittiming.bitrate == CAN_BITRATE_UNKNOWN)
sl->can.bittiming.bitrate = CAN_BITRATE_UNSET;
- sl->rcount = 0;
- sl->xleft = 0;
- spin_unlock_bh(&sl->lock);
-
return 0;
}