diff options
author | Roel Kluin <roel.kluin@gmail.com> | 2009-06-22 19:41:56 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-22 20:32:23 +0200 |
commit | 52e3632ea603ef92757d5d0dedcd9fc8643445e3 (patch) | |
tree | 8ab96a99d898ada201b55ccb30fe7c0e6a10170f /drivers/serial/sunhv.c | |
parent | serial: bfin_5xx: fix building as module when early printk is enabled (diff) | |
download | linux-52e3632ea603ef92757d5d0dedcd9fc8643445e3.tar.xz linux-52e3632ea603ef92757d5d0dedcd9fc8643445e3.zip |
serial: fix off by one errors
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@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Maciej W. Rozycki <macro@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/serial/sunhv.c')
-rw-r--r-- | drivers/serial/sunhv.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c index a94a2ab4b571..1df5325faab2 100644 --- a/drivers/serial/sunhv.c +++ b/drivers/serial/sunhv.c @@ -461,7 +461,7 @@ static void sunhv_console_write_paged(struct console *con, const char *s, unsign break; udelay(1); } - if (limit <= 0) + if (limit < 0) break; page_bytes -= written; ra += written; |