[PATCH] tty: Fix unreasonable write toward closed pty.

From: Ilya Zykov
Date: Wed Dec 19 2012 - 13:59:16 EST


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@xxxxxxx>
---
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)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/