[LTP] [PATCH v2] can: slcan: do not sleep with a spin lock held
Jiri Slaby
jirislaby@kernel.org
Thu Jul 14 12:38:03 CEST 2022
On 13. 07. 22, 17:44, Dario Binacchi wrote:
> We can't call close_candev() with a spin lock held, so release the lock
> before calling it.
>
> Fixes: c4e54b063f42f ("can: slcan: use CAN network device driver API")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Link: https://lore.kernel.org/linux-kernel/Ysrf1Yc5DaRGN1WE@xsang-OptiPlex-9020/
> Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
>
> ---
>
> Changes in v2:
> - Release the lock just before calling the close_candev().
>
> drivers/net/can/slcan/slcan-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c
> index 54d29a410ad5..5214421dedf3 100644
> --- a/drivers/net/can/slcan/slcan-core.c
> +++ b/drivers/net/can/slcan/slcan-core.c
> @@ -689,6 +689,7 @@ static int slc_close(struct net_device *dev)
> clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
> }
> netif_stop_queue(dev);
> + spin_unlock_bh(&sl->lock);
> close_candev(dev);
> sl->can.state = CAN_STATE_STOPPED;
> if (sl->can.bittiming.bitrate == CAN_BITRATE_UNKNOWN)
> @@ -696,7 +697,6 @@ static int slc_close(struct net_device *dev)
>
> sl->rcount = 0;
> sl->xleft = 0;
So all these sets need not be under the spinlock?
If so, you should explain why in the commit message.
> - spin_unlock_bh(&sl->lock);
>
> return 0;
> }
thanks,
--
js
suse labs
More information about the ltp
mailing list