Re: [PATCH] serial: off by one

From: Maciej W. Rozycki
Date: Thu Jun 04 2009 - 08:04:40 EST


On Thu, 4 Jun 2009, Roel Kluin wrote:

> In zs_console_putchar() occurs:
>
> if (zs_transmit_drain(zport, irq))
> write_zsdata(zport, ch);
>
> However if in zs_transmit_drain() no empty Tx Buffer occurs, limit reaches
> -1 => true, and the write still occurs.
>
> This patch changes postfix to prefix decrements in this and similar
> functions to prevent similar mistakes in the future. This decreases the
> iterations with one but the chosen loop count was arbitrary anyway.
>
> In sunhv limit reaches -1, not 0, so the test is off by one.
>
> Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>

Acked-by: Maciej W. Rozycki <macro@xxxxxxxxxxxxxx>

Maciej
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/