Re: [PATCH] serial: off by one

From: David Miller
Date: Thu Jun 04 2009 - 00:18:36 EST


From: Roel Kluin <roel.kluin@xxxxxxxxx>
Date: Thu, 04 Jun 2009 01:20:33 +0200

> 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: David S. Miller <davem@xxxxxxxxxxxxx>
--
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/