From: Bjorn Andersson Date: Fri, 3 Jun 2016 00:48:28 +0000 (-0700) Subject: tty: serial: msm: Don't read off end of tx fifo X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=30acf549ca1e81859a67590ab9ecfce3d1050a0b;p=linux-beck.git tty: serial: msm: Don't read off end of tx fifo For dm uarts in pio mode tx data is transferred to the fifo register 4 bytes at a time, but care is not taken when these 4 bytes spans the end of the xmit buffer so the loop might read up to 3 bytes past the buffer and then skip the actual data at the beginning of the buffer. Fix this by, analogous to the DMA case, make sure the chunk doesn't wrap the xmit buffer. Fixes: 3a878c430fd6 ("tty: serial: msm: Add TX DMA support") Cc: Ivan Ivanov Cc: stable@vger.kernel.org Reported-by: Frank Rowand Reported-by: Nicolas Dechesne Signed-off-by: Bjorn Andersson Acked-by: Andy Gross Tested-by: Frank Rowand Reviewed-by: Stephen Boyd Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index d0384d4cccb1..2c30aaee3e93 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -891,7 +891,7 @@ static void msm_handle_tx(struct uart_port *port) return; } - pio_count = CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE); + pio_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); dma_count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); dma_min = 1; /* Always DMA */