From: Roel Kluin Date: Mon, 22 Jun 2009 17:41:56 +0000 (+0100) Subject: serial: fix off by one errors X-Git-Tag: v2.6.31-rc1~76 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52e3632ea603ef92757d5d0dedcd9fc8643445e3;p=pandora-kernel.git 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 Acked-by: David S. Miller Acked-by: Maciej W. Rozycki Signed-off-by: Andrew Morton Signed-off-by: Alan Cox Signed-off-by: Linus Torvalds --- Reading git-diff-tree failed