aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_ldisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/tty_ldisc.c')
-rw-r--r--drivers/char/tty_ldisc.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
index 913aa8d3f1c5..acd76b767d4c 100644
--- a/drivers/char/tty_ldisc.c
+++ b/drivers/char/tty_ldisc.c
@@ -21,7 +21,6 @@
21#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/smp_lock.h>
25#include <linux/device.h> 24#include <linux/device.h>
26#include <linux/wait.h> 25#include <linux/wait.h>
27#include <linux/bitops.h> 26#include <linux/bitops.h>
@@ -791,17 +790,20 @@ void tty_ldisc_hangup(struct tty_struct *tty)
791 * N_TTY. 790 * N_TTY.
792 */ 791 */
793 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) { 792 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
794 /* Avoid racing set_ldisc */ 793 /* Avoid racing set_ldisc or tty_ldisc_release */
795 mutex_lock(&tty->ldisc_mutex); 794 mutex_lock(&tty->ldisc_mutex);
796 /* Switch back to N_TTY */ 795 if (tty->ldisc) { /* Not yet closed */
797 tty_ldisc_halt(tty); 796 /* Switch back to N_TTY */
798 tty_ldisc_wait_idle(tty); 797 tty_ldisc_halt(tty);
799 tty_ldisc_reinit(tty); 798 tty_ldisc_wait_idle(tty);
800 /* At this point we have a closed ldisc and we want to 799 tty_ldisc_reinit(tty);
801 reopen it. We could defer this to the next open but 800 /* At this point we have a closed ldisc and we want to
802 it means auditing a lot of other paths so this is a FIXME */ 801 reopen it. We could defer this to the next open but
803 WARN_ON(tty_ldisc_open(tty, tty->ldisc)); 802 it means auditing a lot of other paths so this is
804 tty_ldisc_enable(tty); 803 a FIXME */
804 WARN_ON(tty_ldisc_open(tty, tty->ldisc));
805 tty_ldisc_enable(tty);
806 }
805 mutex_unlock(&tty->ldisc_mutex); 807 mutex_unlock(&tty->ldisc_mutex);
806 tty_reset_termios(tty); 808 tty_reset_termios(tty);
807 } 809 }
@@ -866,6 +868,7 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
866 868
867 tty_ldisc_wait_idle(tty); 869 tty_ldisc_wait_idle(tty);
868 870
871 mutex_lock(&tty->ldisc_mutex);
869 /* 872 /*
870 * Now kill off the ldisc 873 * Now kill off the ldisc
871 */ 874 */
@@ -876,6 +879,7 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
876 879
877 /* Ensure the next open requests the N_TTY ldisc */ 880 /* Ensure the next open requests the N_TTY ldisc */
878 tty_set_termios_ldisc(tty, N_TTY); 881 tty_set_termios_ldisc(tty, N_TTY);
882 mutex_unlock(&tty->ldisc_mutex);
879 883
880 /* This will need doing differently if we need to lock */ 884 /* This will need doing differently if we need to lock */
881 if (o_tty) 885 if (o_tty)