Эх сурвалжийг харах

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>
Albert Herranz 15 жил өмнө
parent
commit
698cd335a7

+ 1 - 1
arch/powerpc/boot/ugecon.c

@@ -86,7 +86,7 @@ static void ug_putc(char ch)
 
 
 	while (!ug_is_txfifo_ready() && count--)
 	while (!ug_is_txfifo_ready() && count--)
 		barrier();
 		barrier();
-	if (count)
+	if (count >= 0)
 		ug_raw_putc(ch);
 		ug_raw_putc(ch);
 }
 }
 
 

+ 1 - 1
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c

@@ -120,7 +120,7 @@ static void ug_putc(char ch)
 
 
 	while (!ug_is_txfifo_ready() && count--)
 	while (!ug_is_txfifo_ready() && count--)
 		barrier();
 		barrier();
-	if (count)
+	if (count >= 0)
 		ug_raw_putc(ch);
 		ug_raw_putc(ch);
 }
 }