Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/gamecube/wii: Fix off-by-one error in ugecon/usbgecko_udbg

The retry logic in ug_putc() is broken.

If the TX fifo is not ready and the counter runs out it will have a
value of -1 and no transfer should be attempted. Also, a counter
with a value of 0 means that the TX fifo got ready in the last try
and the transfer should be attempted.

Reported-by: "Juha Leppanen" <juha_motorsportcom@luukku.com>
Signed-off-by: "Juha Leppanen" <juha_motorsportcom@luukku.com>
Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Albert Herranz and committed by
Benjamin Herrenschmidt
698cd335 38e1313f

+2 -2
+1 -1
arch/powerpc/boot/ugecon.c
··· 86 86 87 87 while (!ug_is_txfifo_ready() && count--) 88 88 barrier(); 89 - if (count) 89 + if (count >= 0) 90 90 ug_raw_putc(ch); 91 91 } 92 92
+1 -1
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
··· 120 120 121 121 while (!ug_is_txfifo_ready() && count--) 122 122 barrier(); 123 - if (count) 123 + if (count >= 0) 124 124 ug_raw_putc(ch); 125 125 } 126 126