From: Peter Hurley <peter@hurleysoftware.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Jiri Slaby <jslaby@suse.cz>,
Markus Trippelsdorf <markus@trippelsdorf.de>,
David Howells <dhowells@redhat.com>,
Mikael Pettersson <mikpe@it.uu.se>,
Orion Poplawski <orion@cora.nwra.com>,
Peter Hurley <peter@hurleysoftware.com>
Subject: [PATCH] tty: Fix transient pty write() EIO
Date: Thu, 13 Jun 2013 15:56:37 -0400 [thread overview]
Message-ID: <1371153397-3687-1-git-send-email-peter@hurleysoftware.com> (raw)
In-Reply-To: <51B9F36B.6020802@hurleysoftware.com>
Commit 699390354da6c258b65bf8fa79cfd5feaede50b6
('pty: Ignore slave pty close() if never successfully opened')
introduced a bug with ptys whereby a write() in parallel with an
open() on an existing pty could mistakenly indicate an I/O error.
Only indicate an I/O error if the condition on open() actually exists.
Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
drivers/tty/pty.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 9c2f1bc..dd08d3d 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -238,14 +238,9 @@ static void pty_flush_buffer(struct tty_struct *tty)
static int pty_open(struct tty_struct *tty, struct file *filp)
{
- int retval = -ENODEV;
-
if (!tty || !tty->link)
- goto out;
-
- set_bit(TTY_IO_ERROR, &tty->flags);
+ return -ENODEV;
- retval = -EIO;
if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
goto out;
if (test_bit(TTY_PTY_LOCK, &tty->link->flags))
@@ -256,9 +251,11 @@ static int pty_open(struct tty_struct *tty, struct file *filp)
clear_bit(TTY_IO_ERROR, &tty->flags);
clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
set_bit(TTY_THROTTLED, &tty->flags);
- retval = 0;
+ return 0;
+
out:
- return retval;
+ set_bit(TTY_IO_ERROR, &tty->flags);
+ return -EIO;
}
static void pty_set_termios(struct tty_struct *tty,
--
1.8.1.2
next prev parent reply other threads:[~2013-06-13 19:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-06 11:54 Strange intermittent EIO error when writing to stdout since v3.8.0 Markus Trippelsdorf
2013-06-06 14:18 ` Peter Hurley
2013-06-06 14:37 ` Markus Trippelsdorf
2013-06-07 15:39 ` Peter Hurley
2013-06-07 16:07 ` Markus Trippelsdorf
2013-06-07 18:22 ` Mikael Pettersson
2013-06-13 10:39 ` Markus Trippelsdorf
2013-06-13 14:16 ` Peter Hurley
2013-06-13 14:51 ` Markus Trippelsdorf
2013-06-13 15:25 ` [PATCH] tty: Debug EIO from write() Peter Hurley
2013-06-13 16:16 ` Markus Trippelsdorf
2013-06-13 16:29 ` Peter Hurley
2013-06-13 19:56 ` Peter Hurley [this message]
2013-06-16 17:31 ` [PATCH] tty: Fix transient pty write() EIO Mikael Pettersson
2013-06-07 19:56 ` Strange intermittent EIO error when writing to stdout since v3.8.0 David Howells
2013-06-11 22:14 ` Orion Poplawski
2013-06-13 10:38 ` Markus Trippelsdorf
2013-06-06 14:41 ` Mikael Pettersson
2013-06-06 17:31 ` David Howells
2013-06-06 18:41 ` Markus Trippelsdorf
2013-06-08 18:56 ` Rob Landley
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=1371153397-3687-1-git-send-email-peter@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=dhowells@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=markus@trippelsdorf.de \
--cc=mikpe@it.uu.se \
--cc=orion@cora.nwra.com \
/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