Re: 2.6.31-rc5 regression: Oops when USB Serial disconnected while in use

Alan Cox
2009-08-20T21:57:44Z

> > + /* 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().

Not lost in antiquity:

The logic is this

open
do some opening work
block on carrier
HANGUP
open returns error

cleanup still required

So the tty layer always went that way so that the awkward cases around an
opening failing with a hangup just go away. For the normal drivers which
basically do

open:
tty layer open work
open hardware and set ASYNCB_INITIALIZED
block for carrier

close:
if (!hung_up) {
if initialized
shutdown()
}

the USB layer works really hard to be completely different (in part
because the old code simply didn't implement open semantics properly or
hangup correctly - hence things like mgetty fail on them).

The later patches I was working on were trying to get USB serial to the
point where the model was that drv->open/drv->close were the hardware
init/shutdown and did indeed get called in nice matching open/close pairs
and not re-entered or called unserialized.

Nice spot on the ASYNC v ASYNCB bug Alan btw

Alan (the other one)