Re: [PATCH] tty: Fix close races in USB serial

From: Alan Cox
Date: Tue Nov 04 2008 - 12:37:33 EST


> > - if (port->port.count == (port->console? 1 : 0)) {
> > + if (port->port.count == (port->console ? 2 : 1)) {
>
> Why are you testing for 2 here?

At the point we enter this routine port->port.count is the number of
users of the port. If this is the final close then this is 1 (us), except
if it is the USB console (in which case there will be two references).

The old code dropped the reference count first, the new code drops the
kref and port->tty first, then shuts down the port and then drops the
refcount. That avoids the race where we get the usb serial drivers trying
to stuff bytes into a closed port and the ldisc layer in turn trying to
echo them
- which causes the warnings.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/