Re: [BUG} usb-serial regression in 2.6.21-rc2-git3

Mark Lord
2007-03-12T16:27:14Z

Mark Lord wrote:
> ..and here is a retest with linux-2.6.21-rc3-git7
> of simply plug/wait/unplug a USB hub/serial/parallel/PS2 gizmo.
>
> I have two of these, with different serial port hardware in each,
> and doing this with either of them produces an ooops.
>
...
> 12:12:06 kernel: mct_u232 ttyUSB2: MCT U232 converter now disconnected
> from ttyUSB2
> 12:12:06 kernel: BUG: unable to handle kernel NULL pointer dereference
> at virtual address 00000168
> 12:12:06 kernel: printing eip:
> 12:12:06 kernel: f8ca6542
> 12:12:06 kernel: *pde = 00000000
> 12:12:06 kernel: Oops: 0000 [#2]

Okay, from that part (above), the problem is obvious:
in that the "MCT U232 converter now disconnected" appears,
and then we continue to try and call the driver's method.. Oops!

The hack patch below "fixes" this, but it really just hides whatever
the real problem underneath was:

Signed-off-by: Mark Lord <mlord@pobox.com>
---
--- linux/include/linux/usb/serial.h.orig 2007-03-12 12:18:48.000000000 -0400
+++ linux/include/linux/usb/serial.h 2007-03-12 12:18:23.000000000 -0400
@@ -99,11 +99,19 @@
/* get and set the port private data pointer helper functions */
static inline void *usb_get_serial_port_data (struct usb_serial_port *port)
{
+ if (!port) {
+ WARN_ON(1);
+ return NULL;
+ }
return dev_get_drvdata(&port->dev);
}

static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data)
{
+ if (!port) {
+ WARN_ON(1);
+ return;
+ }
dev_set_drvdata(&port->dev, data);
}