Skip to content

Commit 59a33d8

Browse files
ij-intelgregkh
authored andcommitted
serial: 8250: Protect LCR write in shutdown
The 8250_dw driver needs to potentially perform very complex operations during LCR writes because its BUSY handling prevents updates to LCR while UART is BUSY (which is not fully under our control without those complex operations). Thus, LCR writes should occur under port's lock. Move LCR write under port's lock in serial8250_do_shutdown(). Also split the LCR RMW so that the logic is on a separate line for clarity. Reported-by: Bandal, Shankar <[email protected]> Tested-by: Bandal, Shankar <[email protected]> Tested-by: Murthy, Shanth <[email protected]> Cc: stable <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9c0072b commit 59a33d8

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

drivers/tty/serial/8250/8250_port.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,7 @@ static int serial8250_startup(struct uart_port *port)
23482348
void serial8250_do_shutdown(struct uart_port *port)
23492349
{
23502350
struct uart_8250_port *up = up_to_u8250p(port);
2351+
u32 lcr;
23512352

23522353
serial8250_rpm_get(up);
23532354
/*
@@ -2374,13 +2375,13 @@ void serial8250_do_shutdown(struct uart_port *port)
23742375
port->mctrl &= ~TIOCM_OUT2;
23752376

23762377
serial8250_set_mctrl(port, port->mctrl);
2378+
2379+
/* Disable break condition */
2380+
lcr = serial_port_in(port, UART_LCR);
2381+
lcr &= ~UART_LCR_SBC;
2382+
serial_port_out(port, UART_LCR, lcr);
23772383
}
23782384

2379-
/*
2380-
* Disable break condition and FIFOs
2381-
*/
2382-
serial_port_out(port, UART_LCR,
2383-
serial_port_in(port, UART_LCR) & ~UART_LCR_SBC);
23842385
serial8250_clear_fifos(up);
23852386

23862387
rsa_disable(up);

0 commit comments

Comments
 (0)