tty: Fix hangup race with TIOCSETD ioctl
authorPeter Hurley <peter@hurleysoftware.com>
Sat, 15 Jun 2013 11:04:50 +0000 (07:04 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jul 2013 23:38:35 +0000 (16:38 -0700)
The hangup may already have happened; check for that state also.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/tty_ldisc.c

index 31bd45a2d16b4338923870da8a2af81c808e174f..5819667f5bdb02c38bcfe44dd1787c068a1d0a59 100644 (file)
@@ -546,10 +546,8 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
        old_ldisc = tty->ldisc;
        tty_lock(tty);
 
-       /* FIXME: for testing only */
-       WARN_ON(test_bit(TTY_HUPPED, &tty->flags));
-
-       if (test_bit(TTY_HUPPING, &tty->flags)) {
+       if (test_bit(TTY_HUPPING, &tty->flags) ||
+           test_bit(TTY_HUPPED, &tty->flags)) {
                /* We were raced by the hangup method. It will have stomped
                   the ldisc data and closed the ldisc down */
                tty_ldisc_enable_pair(tty, o_tty);