Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1412659 > unrolled thread

[PATCH] tty: serial: msm: Don't read off end of tx fifo

Started byBjorn Andersson <bjorn.andersson@linaro.org>
First post2016-06-03 02:50 +0200
Last post2016-06-05 20:50 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] tty: serial: msm: Don't read off end of tx fifo Bjorn Andersson <bjorn.andersson@linaro.org> - 2016-06-03 02:50 +0200
    Re: [PATCH] tty: serial: msm: Don't read off end of tx fifo Frank Rowand <frowand.list@gmail.com> - 2016-06-03 06:00 +0200
    Re: [PATCH] tty: serial: msm: Don't read off end of tx fifo Stephen Boyd <sboyd@codeaurora.org> - 2016-06-04 02:10 +0200
    Re: [PATCH] tty: serial: msm: Don't read off end of tx fifo Andy Gross <andy.gross@linaro.org> - 2016-06-05 20:50 +0200

#1412659 — [PATCH] tty: serial: msm: Don't read off end of tx fifo

FromBjorn Andersson <bjorn.andersson@linaro.org>
Date2016-06-03 02:50 +0200
Subject[PATCH] tty: serial: msm: Don't read off end of tx fifo
Message-ID<rFLtg-4E1-25@gated-at.bofh.it>
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: Andy Gross <andy.gross@linaro.org>
Cc: Ivan Ivanov <iivanov.xz@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: stable@vger.kernel.org
Reported-by: Frank Rowand <frowand.list@gmail.com>
Reported-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/tty/serial/msm_serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index b7d80bd57db9..7d62610d9de5 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -726,7 +726,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 */
-- 
2.5.0

[toc] | [next] | [standalone]


#1412768

FromFrank Rowand <frowand.list@gmail.com>
Date2016-06-03 06:00 +0200
Message-ID<rFOr7-6ts-11@gated-at.bofh.it>
In reply to#1412659
On 06/02/16 17:48, Bjorn Andersson wrote:
> 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: Andy Gross <andy.gross@linaro.org>
> Cc: Ivan Ivanov <iivanov.xz@gmail.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: stable@vger.kernel.org
> Reported-by: Frank Rowand <frowand.list@gmail.com>
> Reported-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  drivers/tty/serial/msm_serial.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
> index b7d80bd57db9..7d62610d9de5 100644
> --- a/drivers/tty/serial/msm_serial.c
> +++ b/drivers/tty/serial/msm_serial.c
> @@ -726,7 +726,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 */
> 

Thanks Bjorn.  This eliminates my symptoms on 4.6 and 4.7-rc1.

Tested-by: Frank Rowand <frank.rowand@am.sony.com>

-Frank

[toc] | [prev] | [next] | [standalone]


#1413603

FromStephen Boyd <sboyd@codeaurora.org>
Date2016-06-04 02:10 +0200
Message-ID<rG7k6-1CJ-19@gated-at.bofh.it>
In reply to#1412659
On 06/02, Bjorn Andersson wrote:
> 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: Andy Gross <andy.gross@linaro.org>
> Cc: Ivan Ivanov <iivanov.xz@gmail.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: stable@vger.kernel.org
> Reported-by: Frank Rowand <frowand.list@gmail.com>
> Reported-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---

Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

[toc] | [prev] | [next] | [standalone]


#1414142

FromAndy Gross <andy.gross@linaro.org>
Date2016-06-05 20:50 +0200
Message-ID<rGLhw-1WL-9@gated-at.bofh.it>
In reply to#1412659
On Thu, Jun 02, 2016 at 05:48:28PM -0700, Bjorn Andersson wrote:
> 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: Andy Gross <andy.gross@linaro.org>
> Cc: Ivan Ivanov <iivanov.xz@gmail.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: stable@vger.kernel.org
> Reported-by: Frank Rowand <frowand.list@gmail.com>
> Reported-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Acked-by: Andy Gross <andy.gross@linaro.org>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web