serial: bfin_sport_uart: protect changes to uart_port
authorSonic Zhang <sonic.zhang@analog.com>
Tue, 9 Mar 2010 17:25:34 +0000 (12:25 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 21 May 2010 16:34:27 +0000 (09:34 -0700)
Common serial API says we need to grab the port lock before modifying
the port state to prevent inconsistent state between threads.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/serial/bfin_sport_uart.c

index 8cb0a40..5224db2 100644 (file)
@@ -498,6 +498,8 @@ static void sport_set_termios(struct uart_port *port,
                /* up->parib = 1; */
        }
 
+       spin_lock_irqsave(&up->port.lock, flags);
+
        port->read_status_mask = OE;
        if (termios->c_iflag & INPCK)
                port->read_status_mask |= (FE | PE);
@@ -538,8 +540,6 @@ static void sport_set_termios(struct uart_port *port,
        /* uart baud rate */
        port->uartclk = uart_get_baud_rate(port, termios, old, 0, get_sclk()/16);
 
-       spin_lock_irqsave(&up->port.lock, flags);
-
        /* Disable UART */
        SPORT_PUT_TCR1(up, SPORT_GET_TCR1(up) & ~TSPEN);
        SPORT_PUT_RCR1(up, SPORT_GET_RCR1(up) & ~RSPEN);