]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commit
USB: fix crash when URBs are unlinked after the device is gone
authorAlan Stern <stern@rowland.harvard.edu>
Tue, 21 Oct 2008 19:28:46 +0000 (15:28 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 29 Oct 2008 21:54:40 +0000 (14:54 -0700)
commitcde217a556ec552d28ac9e136c5a94684a69ae94
tree6b8368511301e513c6de8a40dffa357c1064b20e
parente946217e4fdaa67681bbabfa8e6b18641921f750
USB: fix crash when URBs are unlinked after the device is gone

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>
Cc: stable <stable@kernel.org>
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