On Thu, Sep 04, 2003 at 11:34:09AM -0700, Greg KH wrote:
> On Thu, Sep 04, 2003 at 07:21:54PM +0100, Ian Abbott wrote:
> > 
> > I saw a report of a kernel oops on the ftdi-sio-devel list.  The 
> > oops occurred when the [FTDI] USB serial device was unplugged while 
> > doing 'cat /dev/ttyUSB0' and the oops was of the "Unabled to handle 
> > kernel NULL pointer dereference" variety and the oops occurred in 
> > the usb_serial_disconnect function.  To cut to the chase, the 
> > offending lines in usb_serial_disconnect are as follows:
> > 
> >                             while (port->open_count > 0) {
> >                                     __serial_close(port, NULL);
> >                             }
> >                             port->tty->driver_data = NULL;
> > 
> > If port->open_count > 0, the final call to __serial_close sets 
> > port->tty = NULL, resulting in the null pointer dereference on the 
> > final line above.
> 
> Ah, nice catch, thanks.
> So does the following patch solve the problem for you?

Hm, this is probably the better patch for this instead.  Can you try
this?

thanks,

greg k-h


--- a/drivers/usb/serial/usbserial.c    Sat Aug 30 23:27:18 2003
+++ b/drivers/usb/serial/usbserial.c    Thu Sep  4 13:48:45 2003
@@ -556,7 +556,10 @@
                else
                        generic_close(port, filp);
                port->open_count = 0;
-               port->tty = NULL;
+               if (port->tty) {
+                       port->tty->driver_data = NULL;
+                       port->tty = NULL;
+               }
        }
 
        if (port->serial->type->owner)
@@ -1401,12 +1404,9 @@
                for (i = 0; i < serial->num_ports; ++i) {
                        port = &serial->port[i];
                        down (&port->sem);
-                       if (port->tty != NULL) {
-                               while (port->open_count > 0) {
+                       if (port->tty != NULL)
+                               while (port->open_count > 0)
                                        __serial_close(port, NULL);
-                               }
-                               port->tty->driver_data = NULL;
-                       }
                        up (&port->sem);
                }
 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to