From: Jeff Harris <jeff_harris@kentrox.com>
To: alan@linux.intel.com, vapier@gentoo.org, adobriyan@gmail.com
Cc: linux-kernel@vger.kernel.org, Jeff Harris <jeff_harris@kentrox.com>
Subject: [PATCH] tty: Fix tcdrain hang due to tty chars_in_buffer errors
Date: Fri, 17 Jul 2009 11:07:54 -0400 [thread overview]
Message-ID: <1247843274-7462-1-git-send-email-jeff_harris@kentrox.com> (raw)
If a tty driver's chars_in_buffer callback reports an error, the wait loop in
tty_wait_until_sent may never exit until its timeout. A tty device
disconnection will hangup the tty causing the tty_wait_until_sent loop to
wake-up, but if the subsequent call to chars_in_buffer reports an error
instead of zero, the loop will go back to sleep instead of exiting.
A process calling tcdrain will block indefinitely if it calls tcdrain when the
device is disconnected.
Signed-off-by: Jeff Harris <jeff_harris@kentrox.com>
---
drivers/char/tty_ioctl.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index ad6ba4e..306d52e 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -156,7 +156,7 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
if (!timeout)
timeout = MAX_SCHEDULE_TIMEOUT;
if (wait_event_interruptible_timeout(tty->write_wait,
- !tty_chars_in_buffer(tty), timeout) >= 0) {
+ tty_chars_in_buffer(tty) <= 0, timeout) >= 0) {
if (tty->ops->wait_until_sent)
tty->ops->wait_until_sent(tty, timeout);
}
@@ -332,7 +332,7 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
int iclose = ibaud/50, oclose = obaud/50;
int ibinput = 0;
- if (obaud == 0) /* CD dropped */
+ if (obaud == 0) /* CD dropped */
ibaud = 0; /* Clear ibaud to be sure */
termios->c_ispeed = ibaud;
--
1.5.5.1
next reply other threads:[~2009-07-17 15:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-17 15:07 Jeff Harris [this message]
2009-07-17 16:01 ` Alan Cox
2009-07-17 16:36 ` Harris, Jeff
2009-07-17 17:18 ` Alan Cox
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=1247843274-7462-1-git-send-email-jeff_harris@kentrox.com \
--to=jeff_harris@kentrox.com \
--cc=adobriyan@gmail.com \
--cc=alan@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vapier@gentoo.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
all inboxes | Powered by JetHome®