diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2011-07-06 17:03:45 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-07-07 16:29:33 -0400 |
commit | ca5c485f55d326d9a23e4badd05890148aa53f74 (patch) | |
tree | 8dd87458cf563ec1537de3733fea52bf8f403415 /drivers/usb | |
parent | e534c5b831c8b8e9f5edee5c8a37753c808b80dc (diff) |
USB: additional regression fix for device removal
Commit e534c5b831c8b8e9f5edee5c8a37753c808b80dc (USB: fix regression
occurring during device removal) didn't go far enough. It failed to
take into account that when a driver claims multiple interfaces, it may
release them all at the same time. As a result, some interfaces can
get released before they are unregistered, and we deadlock trying to
acquire the bandwidth_mutex that we already own.
This patch (asl478) handles this case by setting the "unregistering"
flag on all the interfaces before removing any of them.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Tested-by: Éric Piel <eric.piel@tremplin-utc.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/core/message.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index e0719b4ee189..0b5ec234c787 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -1147,6 +1147,14 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1147 | * any drivers bound to them (a key side effect) | 1147 | * any drivers bound to them (a key side effect) |
1148 | */ | 1148 | */ |
1149 | if (dev->actconfig) { | 1149 | if (dev->actconfig) { |
1150 | /* | ||
1151 | * FIXME: In order to avoid self-deadlock involving the | ||
1152 | * bandwidth_mutex, we have to mark all the interfaces | ||
1153 | * before unregistering any of them. | ||
1154 | */ | ||
1155 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) | ||
1156 | dev->actconfig->interface[i]->unregistering = 1; | ||
1157 | |||
1150 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { | 1158 | for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { |
1151 | struct usb_interface *interface; | 1159 | struct usb_interface *interface; |
1152 | 1160 | ||
@@ -1156,7 +1164,6 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) | |||
1156 | continue; | 1164 | continue; |
1157 | dev_dbg(&dev->dev, "unregistering interface %s\n", | 1165 | dev_dbg(&dev->dev, "unregistering interface %s\n", |
1158 | dev_name(&interface->dev)); | 1166 | dev_name(&interface->dev)); |
1159 | interface->unregistering = 1; | ||
1160 | remove_intf_ep_devs(interface); | 1167 | remove_intf_ep_devs(interface); |
1161 | device_del(&interface->dev); | 1168 | device_del(&interface->dev); |
1162 | } | 1169 | } |