On Fri, Mar 16, 2012 at 12:54:29PM -0400, Alan Stern wrote: > On Fri, 16 Mar 2012, Johan Hovold wrote: > > > Fix race between probe and open by making sure that the disconnected > > flag is not cleared until all ports have been registered and the serial > > struct is fully initialised. > > > > A call to tty_open while probe is running may get a reference to the > > serial structure in serial_install before its ports have been > > registered. This may lead to usb_serial_core calling driver open before > > port is fully initialised. > > Are you sure that is really the problem? It doesn't seem to make sense > -- before a port has been registered there should be no device file to > open. > > > @@ -1088,6 +1094,7 @@ int usb_serial_probe(struct usb_interface *interface, > > exit: > > /* success */ > > usb_set_intfdata(interface, serial); > > + serial->disconnected = 0; > > module_put(type->driver.owner); > > return 0; > > On the other hand, it certainly seems like a good idea to move this > usb_set_intfdata() call above the loop where the ports are registered. I had a closer look at this today and it seems to me that there is no need to move the usb_set_intfdata as usb_get_intfdata is only called in disconnect, suspend, and resume which will not be called until probe returns (driver core holds device lock). However, I discovered that my patch had the following problem: the disconnected flag must be cleared before calling usb_serial_console_init or it will fail in open. I'll respond to this mail with an updated patch which clears the disconnected flag immediately after the ports have been registered. Thanks, Johan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html