From: Alan Cox <alan@linux.intel.com>
To: Ilya Zykov <ilya@ilyx.ru>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
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: Re: [PATCH] tty: Fix unreasonable write toward closed pty.
Date: Fri, 21 Dec 2012 21:55:05 +0000 [thread overview]
Message-ID: <20121221215505.6dab13ca@bob.linux.org.uk> (raw)
In-Reply-To: <50D20E87.9060403@ilyx.ru>
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
prev parent reply other threads:[~2012-12-21 21:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=20121221215505.6dab13ca@bob.linux.org.uk \
--to=alan@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilya@ilyx.ru \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.