Merge tag 'backlight-next-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / drivers / tty / pty.c
index 6c7151edd7155d2fda27046467d646e714af00e7..b0e2c4847a5d6a51ec70bc88e9ff74052fd1a863 100644 (file)
@@ -110,16 +110,19 @@ static void pty_unthrottle(struct tty_struct *tty)
 static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
 {
        struct tty_struct *to = tty->link;
+       unsigned long flags;
 
        if (tty->stopped)
                return 0;
 
        if (c > 0) {
+               spin_lock_irqsave(&to->port->lock, flags);
                /* Stuff the data into the input queue of the other end */
                c = tty_insert_flip_string(to->port, buf, c);
                /* And shovel */
                if (c)
                        tty_flip_buffer_push(to->port);
+               spin_unlock_irqrestore(&to->port->lock, flags);
        }
        return c;
 }