Merge branch 'upstream' of git://git.infradead.org/users/pcmoore/audit
[firefly-linux-kernel-4.4.55.git] / drivers / tty / tty_port.c
index 3b641d115fd254b5c28ee67a48eb658a79d18385..40b31835f80bc0d8634960a33cc5c3b1ec6d6064 100644 (file)
@@ -193,8 +193,7 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty)
        unsigned long flags;
 
        spin_lock_irqsave(&port->lock, flags);
-       if (port->tty)
-               tty_kref_put(port->tty);
+       tty_kref_put(port->tty);
        port->tty = tty_kref_get(tty);
        spin_unlock_irqrestore(&port->lock, flags);
 }
@@ -520,6 +519,7 @@ void tty_port_close_end(struct tty_port *port, struct tty_struct *tty)
 {
        unsigned long flags;
 
+       tty_ldisc_flush(tty);
        tty->closing = 0;
 
        spin_lock_irqsave(&port->lock, flags);