[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20081104175542.GA1328@kroah.com>
Date: Tue, 4 Nov 2008 09:55:42 -0800
From: Greg KH <greg@...ah.com>
To: Alan Cox <alan@...rguk.ukuu.org.uk>
Cc: linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tty: Fix close races in USB serial
On Tue, Nov 04, 2008 at 05:37:26PM +0000, Alan Cox wrote:
> > > - 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.
Ah, ok, that makes sense, thanks.
You might want to document that in there so that others understand it as
well.
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists