From: Ilya Zykov <ilya@ilyx.ru>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alan Cox <alan@linux.intel.com>, Jiri Slaby <jslaby@suse.cz>,
Peter Hurley <peter@hurleysoftware.com>,
Sasha Levin <levinsasha928@gmail.com>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] tty: Fix unreasonable write toward closed pty.
Date: Wed, 19 Dec 2012 22:59:19 +0400 [thread overview]
Message-ID: <50D20E87.9060403@ilyx.ru> (raw)
We should not write toward the closed pty.
Now it happens, if one side close last file descriptor,
and other side in this moment write to it.
It also prevents scheduling unnecessary work.
Signed-off-by: Ilya Zykov <ilya@ilyx.ru>
---
drivers/tty/pty.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index a82b399..1ce1362 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -116,6 +116,8 @@ static int pty_space(struct tty_struct *to)
static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
{
+ if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
+ return -EIO;
struct tty_struct *to = tty->link;
if (tty->stopped)
next reply other threads:[~2012-12-19 18:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-19 18:59 Ilya Zykov [this message]
2012-12-19 19:10 ` [PATCH] tty: Fix unreasonable write toward closed pty Alan Cox
2012-12-19 19:38 ` Ilya Zykov
2012-12-21 21:55 ` 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=50D20E87.9060403@ilyx.ru \
--to=ilya@ilyx.ru \
--cc=alan@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=levinsasha928@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=peter@hurleysoftware.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