Commit e9cef862 authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman

serial: 8250: Prevent concurrent updates to shadow registers

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: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4516d50a
...@@ -2549,6 +2549,15 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -2549,6 +2549,15 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
port->uartclk / 16); port->uartclk / 16);
quot = serial8250_get_divisor(up, baud, &frac); 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) { if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) {
/* NOTE: If fifo_bug is not set, a user can set RX_trigger. */ /* NOTE: If fifo_bug is not set, a user can set RX_trigger. */
if ((baud < 2400 && !up->dma) || up->fifo_bug) { if ((baud < 2400 && !up->dma) || up->fifo_bug) {
...@@ -2571,15 +2580,6 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -2571,15 +2580,6 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
up->mcr |= UART_MCR_AFE; 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. * Update the per-port timeout.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment