pty: Hold ctrl_lock for packet mode updates
authorPeter Hurley <peter@hurleysoftware.com>
Thu, 16 Oct 2014 19:33:28 +0000 (15:33 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Nov 2014 00:34:36 +0000 (16:34 -0800)
Updates to the packet mode enable require holding the ctrl_lock;
the serialization prevents corruption of adjacent fields.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/pty.c

index bcec4c71a408cd60832d1f1bcf4fdc32e174c777..7a1a53819e22ca5f7ec29bb6c52db8a7fe8e61fd 100644 (file)
@@ -47,7 +47,9 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
        set_bit(TTY_IO_ERROR, &tty->flags);
        wake_up_interruptible(&tty->read_wait);
        wake_up_interruptible(&tty->write_wait);
+       spin_lock_irq(&tty->ctrl_lock);
        tty->packet = 0;
+       spin_unlock_irq(&tty->ctrl_lock);
        /* Review - krefs on tty_link ?? */
        if (!tty->link)
                return;