serial: 8250: Prevent concurrent updates to shadow registers
authorPeter Hurley <peter@hurleysoftware.com>
Thu, 22 Jan 2015 17:24:31 +0000 (12:24 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Feb 2015 18:11:27 +0000 (10:11 -0800)
The port shadow registers, ->fcr and ->mcr, must be protected from
concurrent updates. Relocate the shadow register updates in
serial8250_do_set_termios() to the port lock critical section.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_core.c

index 1449c56506b77334c68b2e0db1df9311e5197f1c..57d13b058a484af9e555250f0e07891821bbec9f 100644 (file)
@@ -2549,6 +2549,15 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
                                  port->uartclk / 16);
        quot = serial8250_get_divisor(up, baud, &frac);
 
+       /*
+        * Ok, we're now changing the port state.  Do it with
+        * interrupts disabled.
+        */
+       serial8250_rpm_get(up);
+       spin_lock_irqsave(&port->lock, flags);
+
+       up->lcr = cval;                                 /* Save computed LCR */
+
        if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) {
                /* NOTE: If fifo_bug is not set, a user can set RX_trigger. */
                if ((baud < 2400 && !up->dma) || up->fifo_bug) {
@@ -2571,15 +2580,6 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
                        up->mcr |= UART_MCR_AFE;
        }
 
-       /*
-        * Ok, we're now changing the port state.  Do it with
-        * interrupts disabled.
-        */
-       serial8250_rpm_get(up);
-       spin_lock_irqsave(&port->lock, flags);
-
-       up->lcr = cval;                                 /* Save computed LCR */
-
        /*
         * Update the per-port timeout.
         */