]> git.baikalelectronics.ru Git - kernel.git/commit
serial: fix off by one errors
authorRoel Kluin <roel.kluin@gmail.com>
Mon, 22 Jun 2009 17:41:56 +0000 (18:41 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 22 Jun 2009 18:32:23 +0000 (11:32 -0700)
commit0d537710ee63e3fb4f1382f2f4108d1bc5a8258e
tree8ab96a99d898ada201b55ccb30fe7c0e6a10170f
parent82ac47ee6f7e21e41d5e4381463498c00967a7fa
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>
drivers/serial/sb1250-duart.c
drivers/serial/sunhv.c
drivers/serial/zs.c