summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2014-11-11 09:12:28 +1100
committerMichael Ellerman <mpe@ellerman.id.au>2014-11-12 13:47:20 +1100
commitcd32e2dcc9de6c27ecbbfc0e2079fb64b42bad5f (patch)
treef53c940f8194f1705a60d4508194ce1160f6a76c /arch/powerpc/kernel
parent6609ed14de75bde7a99b33e9be9f1873da91f07d (diff)
downloadop-kernel-dev-cd32e2dcc9de6c27ecbbfc0e2079fb64b42bad5f.zip
op-kernel-dev-cd32e2dcc9de6c27ecbbfc0e2079fb64b42bad5f.tar.gz
powerpc: Fix 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") Signed-off-by: Anton Blanchard <anton@samba.org> [mpe: Add some newlines for readability while we're here] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/udbg_16550.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel/udbg_16550.c
index 6e7c492..411116c 100644
--- a/arch/powerpc/kernel/udbg_16550.c
+++ b/arch/powerpc/kernel/udbg_16550.c
@@ -69,8 +69,12 @@ 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;
}
OpenPOWER on IntegriCloud