Re: [PATCH] usb: usbfs: Fix deadlock of khubd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Samstag, 6. März 2010 16:34:31 schrieb Alan Stern:
> On Sat, 6 Mar 2010, Oliver Neukum wrote:
> 
> > From e58722a5fc0c00bceaea1f70d5024f6325ac3a6c Mon Sep 17 00:00:00 2001
> > From: Oliver Neukum <oliver@xxxxxxxxxx>
> > Date: Sat, 6 Mar 2010 12:09:41 +0100
> > Subject: [PATCH] usb: usbfs: Fix deadlock of khubd
> > 
> > The caller of usbfs_conn_disc_event() already holds usbfs_mutex.
> > Don't take it again.
> 
> That's not true.  The caller holds usbfs_mutex only when the action is 
> USB_DEVICE_REMOVE.  Not when the action is USB_DEVICE_ADD or USB_BUS_*.

That is, there's no obvious solution but it is inelegant.

	Regards
		Oliver

>From d0da57c398ccc23a5b50ce7353b32983f9270eb5 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oliver@xxxxxxxxxx>
Date: Sat, 6 Mar 2010 17:16:51 +0100
Subject: [PATCH] usb: usbfs: Fix deadlock of khubd

The caller of usbfs_conn_disc_event() already holds usbfs_mutex.
Don't take it again.

Signed-off-by: Oliver Neukum <neukum@xxxxxxxxxxxxx>
---
 drivers/usb/core/devices.c |    3 +--
 drivers/usb/core/inode.c   |    4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index c83c975..08def6b 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -155,11 +155,10 @@ static const struct class_info clas_info[] =
 
 /*****************************************************************/
 
+/* the caller holds usbfs_mutex */
 void usbfs_conn_disc_event(void)
 {
-	mutex_lock(&usbfs_mutex);
 	conndiscevcnt++;
-	mutex_unlock(&usbfs_mutex);
 	wake_up(&deviceconndiscwq);
 }
 
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 97b40ce..2d332af 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -740,7 +740,11 @@ static int usbfs_notify(struct notifier_block *self, unsigned long action, void
 	}
 
 	usbfs_update_special();
+	if (action != USB_DEVICE_REMOVE)
+		mutex_lock(&usbfs_mutex);
 	usbfs_conn_disc_event();
+	if (action != USB_DEVICE_REMOVE)
+		mutex_unlock(&usbfs_mutex);
 	return NOTIFY_OK;
 }
 
-- 
1.6.4.2

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

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux