usb-serial: fix crash when sub-driver updates firmware
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 27 May 2009 15:25:52 +0000 (11:25 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 22 Oct 2009 04:51:09 +0000 (21:51 -0700)
commit66f7234efcc7182ee7f3e5884ae385b2ff4dce87
tree86eea8a943c7994b5ed82aacddc5c061e7492dd3
parent8521cde0ae1b66dd68228ac674d9f0609767dc0a
usb-serial: fix crash when sub-driver updates firmware

commit 0a3c8549ea7e94d74a41096d42bc6cdf43d183bf upstream.

This patch (as1244) fixes a crash in usb-serial that occurs when a
sub-driver returns a positive value from its attach method, indicating
that new firmware was loaded and the device will disconnect and
reconnect.  The usb-serial core then skips the step of registering the
port devices; when the disconnect occurs, the attempt to unregister
the ports fails dramatically.

This problem shows up with Keyspan devices and it might affect others
as well.

When the attach method returns a positive value, the patch sets
num_ports to 0.  This tells usb_serial_disconnect() not to try
unregistering any of the ports; instead they are cleaned up by
destroy_serial().

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/usb-serial.c