From: Peter Hurley Date: Wed, 5 Nov 2014 17:12:48 +0000 (-0500) Subject: tty: Check tty->count instead of TTY_CLOSING in tty_reopen() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=216030ec55e08646be629ee32725c0189ad74c9a;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git tty: Check tty->count instead of TTY_CLOSING in tty_reopen() Although perhaps not obvious, the TTY_CLOSING bit is set when the tty count has been decremented to 0 (which occurs while holding tty_lock). The only other case when tty count is 0 during a re-open is when a legacy BSD pty master has been opened in parallel but after the pty slave, which is unsupported and returns an error. Thus !tty->count contains the complete set of degenerate conditions under which a tty open fails. Reviewed-by: Alan Cox Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 168382baf370..0eaf632ad39e 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1452,7 +1452,7 @@ static int tty_reopen(struct tty_struct *tty) { struct tty_driver *driver = tty->driver; - if (test_bit(TTY_CLOSING, &tty->flags)) + if (!tty->count) return -EIO; if (driver->type == TTY_DRIVER_TYPE_PTY &&