Re: TTY: ntty, add one more sanity check

From: Greg KH
Date: Tue Jun 07 2011 - 13:20:46 EST


On Sun, Jun 05, 2011 at 02:16:17PM +0200, Jiri Slaby wrote:
> With the previous patch, we fixed another bug where read_buf was freed
> while we still was in n_tty_read. We currently check whether read_buf
> is NULL at the start of the function. Add one more check after we wake
> up from waiting for input.
>
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> Cc: Alan Cox <alan@xxxxxxxxxxxxxxxxxxx>
> ---
> drivers/tty/n_tty.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
> index 95d0a9c..c62c856 100644
> --- a/drivers/tty/n_tty.c
> +++ b/drivers/tty/n_tty.c
> @@ -1785,6 +1785,7 @@ do_it_again:
> break;
> }
> timeout = schedule_timeout(timeout);
> + BUG_ON(!tty->read_buf);
> continue;
> }
> __set_current_state(TASK_RUNNING);

This doesn't apply anymore without some fuzz as stuff has changed in
this area in Linus's tree.

Can you refresh it and resend it so that I know it's correct?

Or, just verify that the diff below is correct, and I'll take that one.

thanks,

greg k-h

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 0ad3288..c3954fb 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1815,6 +1815,7 @@ do_it_again:
/* FIXME: does n_tty_set_room need locking ? */
n_tty_set_room(tty);
timeout = schedule_timeout(timeout);
+ BUG_ON(!tty->read_buf);
continue;
}
__set_current_state(TASK_RUNNING);
--
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/