Commit 4b43ad93 authored by Anton Blanchard's avatar Anton Blanchard Committed by Greg Kroah-Hartman

powerpc: Fix bad NULL pointer check in udbg_uart_getc_poll()

commit cd32e2dc upstream.

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: 30925748 ("powerpc: Cleanup udbg_16550 and add support for LPC PIO-only UARTs")
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
[mpe: Add some newlines for readability while we're here]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a7c3ff29
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment