]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
USB: fix crash when URBs are unlinked after the device is gone
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 30 Oct 2008 19:10:11 +0000 (19:10 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 7 Nov 2008 03:05:38 +0000 (19:05 -0800)
commitce372e05a1442405eed3e386205ad401307cea61
tree256a4647abc30997d2b9ba7b949551c01b386858
parent2ed0ed09a6bb5dcb4c497908d2873e3c6096f27f
USB: fix crash when URBs are unlinked after the device is gone

commit cde217a556ec552d28ac9e136c5a94684a69ae94 upstream

This patch (as1151) protects usbcore against drivers that try to
unlink an URB after the URB's device or bus have been removed.  The
core does not currently check for this, and certain drivers can cause
a crash if they are running while an HCD is unloaded.

Certainly it would be best to fix the guilty drivers.  But a little
defensive programming doesn't hurt, especially since it appears that
quite a few drivers need to be fixed.

The patch prevents the problem by grabbing a reference to the device
while an unlink is in progress and using a new spinlock to synchronize
unlinks with device removal.  (There's no need to acquire a reference
to the bus as well, since the device structure itself keeps a
reference to the bus.)  In addition, the kerneldoc is updated to
indicate that URBs should not be unlinked after the disconnect method
returns.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/hcd.c
drivers/usb/core/hcd.h
drivers/usb/core/hub.c
drivers/usb/core/urb.c