netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [REPOST PATCH] net/usbnet: avoid recursive locking in usbnet_stop()
@ 2012-03-07 20:19 Sebastian Andrzej Siewior
  2012-03-08  8:38 ` Oliver Neukum
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2012-03-07 20:19 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: netdev, linux-usb

|kernel BUG at kernel/rtmutex.c:724!
|[<c029599c>] (rt_spin_lock_slowlock+0x108/0x2bc) from [<c01c2330>] (defer_bh+0x1c/0xb4)
|[<c01c2330>] (defer_bh+0x1c/0xb4) from [<c01c3afc>] (rx_complete+0x14c/0x194)
|[<c01c3afc>] (rx_complete+0x14c/0x194) from [<c01cac88>] (usb_hcd_giveback_urb+0xa0/0xf0)
|[<c01cac88>] (usb_hcd_giveback_urb+0xa0/0xf0) from [<c01e1ff4>] (musb_giveback+0x34/0x40)
|[<c01e1ff4>] (musb_giveback+0x34/0x40) from [<c01e2b1c>] (musb_advance_schedule+0xb4/0x1c0)
|[<c01e2b1c>] (musb_advance_schedule+0xb4/0x1c0) from [<c01e2ca8>] (musb_cleanup_urb.isra.9+0x80/0x8c)
|[<c01e2ca8>] (musb_cleanup_urb.isra.9+0x80/0x8c) from [<c01e2ed0>] (musb_urb_dequeue+0xec/0x108)
|[<c01e2ed0>] (musb_urb_dequeue+0xec/0x108) from [<c01cbb90>] (unlink1+0xbc/0xcc)
|[<c01cbb90>] (unlink1+0xbc/0xcc) from [<c01cc2ec>] (usb_hcd_unlink_urb+0x54/0xa8)
|[<c01cc2ec>] (usb_hcd_unlink_urb+0x54/0xa8) from [<c01c2a84>] (unlink_urbs.isra.17+0x2c/0x58)
|[<c01c2a84>] (unlink_urbs.isra.17+0x2c/0x58) from [<c01c2b44>] (usbnet_terminate_urbs+0x94/0x10c)
|[<c01c2b44>] (usbnet_terminate_urbs+0x94/0x10c) from [<c01c2d68>] (usbnet_stop+0x100/0x15c)
|[<c01c2d68>] (usbnet_stop+0x100/0x15c) from [<c020f718>] (__dev_close_many+0x94/0xc8)

defer_bh() takes the lock which is hold during unlink_urbs(). The safe
walk suggest that the skb will be removed from the list and this is done
by defer_bh() so it seems to be okay to drop the lock here.

Cc: stable@kernel.org
Reported-by: Aníbal Almeida Pinto <anibal.pinto@efacec.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
According to [0] the usb driver has to assume that the HCD will call the
->complete() callback and therefore not hold any lock which are acquired
in the ->complete() callback.

[0] http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commitdiff;h=371f3b49f2cb1a8b6ac09b6b108841ca92349eb1;hp=2a5be8783e0016d15e7907ddd212b2c312e196eb 

 drivers/net/usb/usbnet.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index fae0fbd..81b96e3 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -589,6 +589,7 @@ static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
 		entry = (struct skb_data *) skb->cb;
 		urb = entry->urb;
 
+		spin_unlock_irqrestore(&q->lock, flags);
 		// during some PM-driven resume scenarios,
 		// these (async) unlinks complete immediately
 		retval = usb_unlink_urb (urb);
@@ -596,6 +597,7 @@ static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
 			netdev_dbg(dev->net, "unlink urb err, %d\n", retval);
 		else
 			count++;
+		spin_lock_irqsave(&q->lock, flags);
 	}
 	spin_unlock_irqrestore (&q->lock, flags);
 	return count;
-- 
1.7.9

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

* Re: [REPOST PATCH] net/usbnet: avoid recursive locking in usbnet_stop()
  2012-03-07 20:19 [REPOST PATCH] net/usbnet: avoid recursive locking in usbnet_stop() Sebastian Andrzej Siewior
@ 2012-03-08  8:38 ` Oliver Neukum
       [not found]   ` <201203080938.17604.oneukum-l3A5Bk7waGM@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Neukum @ 2012-03-08  8:38 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: netdev, linux-usb

Am Mittwoch, 7. März 2012, 21:19:28 schrieb Sebastian Andrzej Siewior:
> Cc: stable@kernel.org
> Reported-by: Aníbal Almeida Pinto <anibal.pinto@efacec.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Oliver Neukum <oliver@neukum.org>

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

* Re: [REPOST PATCH] net/usbnet: avoid recursive locking in usbnet_stop()
       [not found]   ` <201203080938.17604.oneukum-l3A5Bk7waGM@public.gmane.org>
@ 2012-03-08  8:50     ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2012-03-08  8:50 UTC (permalink / raw)
  To: oneukum-l3A5Bk7waGM
  Cc: bigeasy-hfZtesqFncYOwBW4kG4KsQ, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA

From: Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org>
Date: Thu, 8 Mar 2012 09:38:17 +0100

> Am Mittwoch, 7. März 2012, 21:19:28 schrieb Sebastian Andrzej Siewior:
>> Cc: stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
>> Reported-by: Aníbal Almeida Pinto <anibal.pinto-K2AfXPJZHq/QT0dZR+AlfA@public.gmane.org>
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> Acked-by: Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2012-03-08  8:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-07 20:19 [REPOST PATCH] net/usbnet: avoid recursive locking in usbnet_stop() Sebastian Andrzej Siewior
2012-03-08  8:38 ` Oliver Neukum
     [not found]   ` <201203080938.17604.oneukum-l3A5Bk7waGM@public.gmane.org>
2012-03-08  8:50     ` David Miller

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).