]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
tty: Allow safe access to termios for set_ldisc() handlers
authorPeter Hurley <peter@hurleysoftware.com>
Wed, 5 Nov 2014 18:11:41 +0000 (13:11 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Nov 2014 22:57:27 +0000 (14:57 -0800)
Allow a tty driver to safely access termios settings while handling
the set_ldisc() notification. UART drivers use the set_ldisc()
notification to check if the N_PPS line discipline is being enabled;
if so, modem status interrupts may also need to be enabled. Conversely,
modem status interrupts may need to be disabled if switching away
from the N_PPS line discipline.

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

index b66a81d0549e3171420ae948ec3a24ef74987836..3737f55272d2c1184463edc3714f89fb2724730e 100644 (file)
@@ -572,8 +572,11 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
                tty_ldisc_restore(tty, old_ldisc);
        }
 
-       if (tty->ldisc->ops->num != old_ldisc->ops->num && tty->ops->set_ldisc)
+       if (tty->ldisc->ops->num != old_ldisc->ops->num && tty->ops->set_ldisc) {
+               down_read(&tty->termios_rwsem);
                tty->ops->set_ldisc(tty);
+               up_read(&tty->termios_rwsem);
+       }
 
        /* At this point we hold a reference to the new ldisc and a
           reference to the old ldisc, or we hold two references to