Skip to content

Commit 86ee55e

Browse files
Dan Carpentergregkh
authored andcommitted
serial: 8250_pci1xxxx: fix off by one in pci1xxxx_process_read_data()
These > comparisons should be >= to prevent writing one element beyond the end of the rx_buff[] array. The rx_buff[] buffer has RX_BUF_SIZE elements. Fix the buffer overflow. Fixes: aba8290 ("8250: microchip: pci1xxxx: Add Burst mode reception support in uart driver for writing into FIFO") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/ZZ7vIfj7Jgh-pJn8@moroto Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e15c99b commit 86ee55e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/tty/serial/8250/8250_pci1xxxx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static void pci1xxxx_process_read_data(struct uart_port *port,
302302
* to read, the data is received one byte at a time.
303303
*/
304304
while (valid_burst_count--) {
305-
if (*buff_index > (RX_BUF_SIZE - UART_BURST_SIZE))
305+
if (*buff_index >= (RX_BUF_SIZE - UART_BURST_SIZE))
306306
break;
307307
burst_buf = (u32 *)&rx_buff[*buff_index];
308308
*burst_buf = readl(port->membase + UART_RX_BURST_FIFO);
@@ -311,7 +311,7 @@ static void pci1xxxx_process_read_data(struct uart_port *port,
311311
}
312312

313313
while (*valid_byte_count) {
314-
if (*buff_index > RX_BUF_SIZE)
314+
if (*buff_index >= RX_BUF_SIZE)
315315
break;
316316
rx_buff[*buff_index] = readb(port->membase +
317317
UART_RX_BYTE_FIFO);

0 commit comments

Comments
 (0)