Skip to contentSkip to conversation

powerpc: Bad NULL pointer check in udbg_uart_getc_poll

PATCH New Anton Blanchard 1 participant 1 message Nov 10, 2014 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Bad NULL pointer check in udbg_uart_getc_poll

We have some code in udbg_uart_getc_poll that tries to protect against a NULL udbg_uart_in, but gets it all wrong.

Found with the LLVM static analyzer (scan-build).

Fixes 309257484cc1 ("powerpc: Cleanup udbg_16550 and add support for LPC PIO-only UARTs")
---
 arch/powerpc/kernel/udbg_16550.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kernel/udbg_16550.c +3 -1
index 6e7c492..3faf393 100644
@@ -69,7 +69,9 @@ static void udbg_uart_putc(char c)
 
 static int udbg_uart_getc_poll(void)
 {
-	if (!udbg_uart_in || !(udbg_uart_in(UART_LSR) & LSR_DR))
+	if (!udbg_uart_in)
+		return -1;
+	if (!(udbg_uart_in(UART_LSR) & LSR_DR))
 		return udbg_uart_in(UART_RBR);
 	return -1;
 }
Signature · 1 line
1.9.1