pty: Don't claim slave's ctrl_lock for master's packet mode
[firefly-linux-kernel-4.4.55.git] / drivers / tty / n_tty.c
index d521058ee55a98236fc69ee520ca1eed5dfaae9f..cd725cc6e21e0b340a79d5780ec9de31c5ed6b39 100644 (file)
@@ -351,13 +351,13 @@ static void n_tty_packet_mode_flush(struct tty_struct *tty)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&tty->ctrl_lock, flags);
        if (tty->link->packet) {
+               spin_lock_irqsave(&tty->ctrl_lock, flags);
                tty->ctrl_status |= TIOCPKT_FLUSHREAD;
+               spin_unlock_irqrestore(&tty->ctrl_lock, flags);
                if (waitqueue_active(&tty->link->read_wait))
                        wake_up_interruptible(&tty->link->read_wait);
        }
-       spin_unlock_irqrestore(&tty->ctrl_lock, flags);
 }
 
 /**