Re: Oops in usb-serial with keyspan adapter on current upstream

From: Alan Stern
Date: Mon May 25 2009 - 11:17:55 EST


On Mon, 25 May 2009, Benjamin Herrenschmidt wrote:

> Found it. Patch below.
>
> usb-serial: Fix crash when sub-driver attach() returns positive value
>
> This fixes a crash in usb-serial that typically happens with keyspan USB
> devices, though it would happen potentially with anything that returns
> a positive value from the subdriver's attach() method to indicate that
> a FW was loaded and the device will disconnect and reconnect.
>
> What happens is that we haven't yet initialized the struct device embedded
> inside the struct usb_serial_port when we call "exit:" and return
> from probe().
>
> Later, when we get the disconnect() call, usb_serial_disconnect() tries
> to do a device_del() and put_device() on all the ports, despite the fact
> that in this case, the struct device wasn't initialized. This causes the
> device core to crash (right, it should be more robust).

Very clever. Does this simpler patch also fix the problem?

Alan Stern


Index: usb-2.6/drivers/usb/serial/usb-serial.c
===================================================================
--- usb-2.6.orig/drivers/usb/serial/usb-serial.c
+++ usb-2.6/drivers/usb/serial/usb-serial.c
@@ -974,6 +974,7 @@ int usb_serial_probe(struct usb_interfac
if (retval > 0) {
/* quietly accept this device, but don't bind to a
serial port as it's about to disappear */
+ serial->num_ports = 0;
goto exit;
}
}

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