linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: Fix unreasonable write toward closed pty.
@ 2012-12-19 18:59 Ilya Zykov
  2012-12-19 19:10 ` Alan Cox
  2012-12-21 21:55 ` Alan Cox
  0 siblings, 2 replies; 4+ messages in thread
From: Ilya Zykov @ 2012-12-19 18:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alan Cox, Jiri Slaby, Peter Hurley, Sasha Levin, linux-serial,
	linux-kernel

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)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-21 21:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-19 18:59 [PATCH] tty: Fix unreasonable write toward closed pty Ilya Zykov
2012-12-19 19:10 ` Alan Cox
2012-12-19 19:38   ` Ilya Zykov
2012-12-21 21:55 ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).