2009-03-10 09:44:24

by Sonic Zhang

[permalink] [raw]
Subject: [PATCH 03/18] Blackfin Serial Driver: fix a bug in dma circle rx buffer handling - v2

The rx buffer tail index may increase to UART_XMIT_SIZE, which is not a valid
index, at the beginning of the Loop. The exit check should happen after this
index is adjusted properly.

Reported-by: Qian Zhang <[email protected]>
Signed-off-by: Sonic Zhang <[email protected]>
Signed-off-by: Bryan Wu <[email protected]>
---
drivers/serial/bfin_5xx.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 350bfc4..1e027e3 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -402,9 +402,11 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
else
flg = TTY_NORMAL;

- for (i = uart->rx_dma_buf.tail; i != uart->rx_dma_buf.head; i++) {
+ for (i = uart->rx_dma_buf.tail; ; i++) {
if (i >= UART_XMIT_SIZE)
i = 0;
+ if (i == uart->rx_dma_buf.head)
+ break;
if (!uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i]))
uart_insert_char(&uart->port, status, OE,
uart->rx_dma_buf.buf[i], flg);
--
1.6.0


2009-03-11 19:28:49

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 03/18] Blackfin Serial Driver: fix a bug in dma circle rx buffer handling - v2

On Tue, 10 Mar 2009 17:49:29 +0800
sonic zhang <[email protected]> wrote:

> The rx buffer tail index may increase to UART_XMIT_SIZE, which is not a valid
> index, at the beginning of the Loop. The exit check should happen after this
> index is adjusted properly.
>
> Reported-by: Qian Zhang <[email protected]>
> Signed-off-by: Sonic Zhang <[email protected]>
> Signed-off-by: Bryan Wu <[email protected]>
> ---
> drivers/serial/bfin_5xx.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
> index 350bfc4..1e027e3 100644
> --- a/drivers/serial/bfin_5xx.c
> +++ b/drivers/serial/bfin_5xx.c
> @@ -402,9 +402,11 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
> else
> flg = TTY_NORMAL;
>
> - for (i = uart->rx_dma_buf.tail; i != uart->rx_dma_buf.head; i++) {
> + for (i = uart->rx_dma_buf.tail; ; i++) {
> if (i >= UART_XMIT_SIZE)
> i = 0;
> + if (i == uart->rx_dma_buf.head)
> + break;
> if (!uart_handle_sysrq_char(&uart->port, uart->rx_dma_buf.buf[i]))
> uart_insert_char(&uart->port, status, OE,
> uart->rx_dma_buf.buf[i], flg);

This appears to be identical to the v1 ptch whcih I merged.