lkml.org 
[lkml]   [2012]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] tty: Fix unreasonable write toward closed pty.
On Wed, 19 Dec 2012 22:59:19 +0400
Ilya Zykov <ilya@ilyx.ru> wrote:

> 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;

This

a) doesn't do anything in many cases because there is no lock to make
the test_bit meaningful

b) produces an obvious compiler warning



\
 
 \ /
  Last update: 2012-12-21 23:01    [W:0.044 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site