Skip to content

Commit

Permalink
tty: Allow safe access to termios for set_ldisc() handlers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Hurley authored and Greg Kroah-Hartman committed Nov 6, 2014
1 parent 3f40f5b commit 9191aaa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/tty/tty_ldisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9191aaa

Please sign in to comment.