From: Greg KH <greg@kroah.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: Fix close races in USB serial
Date: Tue, 4 Nov 2008 09:55:42 -0800 [thread overview]
Message-ID: <20081104175542.GA1328@kroah.com> (raw)
In-Reply-To: <20081104173726.0271939d@lxorguk.ukuu.org.uk>
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
prev parent reply other threads:[~2008-11-04 19:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-04 15:29 Alan Cox
2008-11-04 17:11 ` Greg KH
2008-11-04 17:37 ` Alan Cox
2008-11-04 17:55 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081104175542.GA1328@kroah.com \
--to=greg@kroah.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome