linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: slcan: do not sleep with a spin lock held
@ 2022-07-13 15:19 Dario Binacchi
  2022-07-13 15:35 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Dario Binacchi @ 2022-07-13 15:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: Richard Palethorpe, Jeroen Hofstee, Linux Memory Management List,
	kernel test robot, lkp, lkp, ltp, Dario Binacchi,
	David S. Miller, Eric Dumazet, Greg Kroah-Hartman,
	Jakub Kicinski, Jiri Slaby, Marc Kleine-Budde, Paolo Abeni,
	Sebastian Andrzej Siewior, Vincent Mailhol, Wolfgang Grandegger,
	linux-can, netdev

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>

---

 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..6aaf2986effc 100644
--- a/drivers/net/can/slcan/slcan-core.c
+++ b/drivers/net/can/slcan/slcan-core.c
@@ -688,6 +688,7 @@ static int slc_close(struct net_device *dev)
 		/* TTY discipline is running. */
 		clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
 	}
+	spin_unlock_bh(&sl->lock);
 	netif_stop_queue(dev);
 	close_candev(dev);
 	sl->can.state = CAN_STATE_STOPPED;
@@ -696,7 +697,6 @@ static int slc_close(struct net_device *dev)
 
 	sl->rcount   = 0;
 	sl->xleft    = 0;
-	spin_unlock_bh(&sl->lock);
 
 	return 0;
 }
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] can: slcan: do not sleep with a spin lock held
  2022-07-13 15:19 [PATCH] can: slcan: do not sleep with a spin lock held Dario Binacchi
@ 2022-07-13 15:35 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2022-07-13 15:35 UTC (permalink / raw)
  To: Dario Binacchi
  Cc: linux-kernel, Richard Palethorpe, Jeroen Hofstee,
	Linux Memory Management List, kernel test robot, lkp, lkp, ltp,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Jiri Slaby,
	Marc Kleine-Budde, Paolo Abeni, Sebastian Andrzej Siewior,
	Vincent Mailhol, Wolfgang Grandegger, linux-can, netdev

On Wed, Jul 13, 2022 at 05:19:47PM +0200, 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>
> 
> ---
> 
>  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..6aaf2986effc 100644
> --- a/drivers/net/can/slcan/slcan-core.c
> +++ b/drivers/net/can/slcan/slcan-core.c
> @@ -688,6 +688,7 @@ static int slc_close(struct net_device *dev)
>  		/* TTY discipline is running. */
>  		clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
>  	}
> +	spin_unlock_bh(&sl->lock);
>  	netif_stop_queue(dev);

Can you have a lock held when calling netif_stop_queue()?  You don't
mention this in your changelog text :(

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-13 15:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 15:19 [PATCH] can: slcan: do not sleep with a spin lock held Dario Binacchi
2022-07-13 15:35 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).