Skip to content

Commit 270db79

Browse files
hvilleneuvedooSasha Levin
authored andcommitted
serial: sc16is7xx: fix invalid FIFO access with special register set
[ Upstream commit 7d3b793 ] When enabling access to the special register set, Receiver time-out and RHR interrupts can happen. In this case, the IRQ handler will try to read from the FIFO thru the RHR register at address 0x00, but address 0x00 is mapped to DLL register, resulting in erroneous FIFO reading. Call graph example: sc16is7xx_startup(): entry sc16is7xx_ms_proc(): entry sc16is7xx_set_termios(): entry sc16is7xx_set_baud(): DLH/DLL = $009C --> access special register set sc16is7xx_port_irq() entry --> IIR is 0x0C sc16is7xx_handle_rx() entry sc16is7xx_fifo_read(): --> unable to access FIFO (RHR) because it is mapped to DLL (LCR=LCR_CONF_MODE_A) sc16is7xx_set_baud(): exit --> Restore access to general register set Fix the problem by claiming the efr_lock mutex when accessing the Special register set. Fixes: dfeae61 ("serial: sc16is7xx") Cc: [email protected] Signed-off-by: Hugo Villeneuve <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> [ Resolve minor conflicts ] Signed-off-by: Bin Lan <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 4902332 commit 270db79

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/tty/serial/sc16is7xx.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ static int sc16is7xx_set_baud(struct uart_port *port, int baud)
545545
SC16IS7XX_MCR_CLKSEL_BIT,
546546
prescaler == 1 ? 0 : SC16IS7XX_MCR_CLKSEL_BIT);
547547

548+
549+
mutex_lock(&one->efr_lock);
550+
548551
/* Open the LCR divisors for configuration */
549552
sc16is7xx_port_write(port, SC16IS7XX_LCR_REG,
550553
SC16IS7XX_LCR_CONF_MODE_A);
@@ -558,6 +561,8 @@ static int sc16is7xx_set_baud(struct uart_port *port, int baud)
558561
/* Put LCR back to the normal mode */
559562
sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, lcr);
560563

564+
mutex_unlock(&one->efr_lock);
565+
561566
return DIV_ROUND_CLOSEST((clk / prescaler) / 16, div);
562567
}
563568

0 commit comments

Comments
 (0)