Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / tty / tty_ldisc.c
index c5782294e53261e701f13292b5732c231cfb9d14..d794087c327e5b6ed85c647a66bb19114973aad3 100644 (file)
@@ -64,7 +64,9 @@ static void put_ldisc(struct tty_ldisc *ld)
                return;
        }
        raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-       wake_up(&ld->wq_idle);
+
+       if (waitqueue_active(&ld->wq_idle))
+               wake_up(&ld->wq_idle);
 }
 
 /**
@@ -934,17 +936,17 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
         * race with the set_ldisc code path.
         */
 
-       tty_lock_pair(tty, o_tty);
        tty_ldisc_halt(tty);
-       tty_ldisc_flush_works(tty);
-       if (o_tty) {
+       if (o_tty)
                tty_ldisc_halt(o_tty);
+
+       tty_ldisc_flush_works(tty);
+       if (o_tty)
                tty_ldisc_flush_works(o_tty);
-       }
 
+       tty_lock_pair(tty, o_tty);
        /* This will need doing differently if we need to lock */
        tty_ldisc_kill(tty);
-
        if (o_tty)
                tty_ldisc_kill(o_tty);