On Wed, 19 Aug 2009, Alan Cox wrote: > > So Alan, what's the explanation? An unsuccessful open method call > > should not lead to a close method call. > > For tty it always has since back in 0.9x, and most drivers depend upon > this behaviour. Curiouser and curiouser... Okay Bruno, try out this patch and let's see if it helps. It should fix the problem with the pl2303. I'm not so sure about the FTDI device because that driver maintains its own reference count for its private data. 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 @@ -209,8 +209,13 @@ static int serial_open (struct tty_struc * to be acquired while serial->disc_mutex is held. */ mutex_unlock(&serial->disc_mutex); + + /* For reasons that have been lost in antiquity, the TTY layer calls + * our close method even if the open call fails. Hence we must not + * drop the reference obtained by usb_serial_get_by_index(). + */ if (retval) - goto bailout_serial_put; + return retval; if (mutex_lock_interruptible(&port->mutex)) { retval = -ERESTARTSYS; @@ -276,8 +281,6 @@ bailout_mutex_unlock: mutex_unlock(&port->mutex); bailout_port_put: put_device(&port->dev); -bailout_serial_put: - usb_serial_put(serial); return retval; } -- 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