1 From cd32e2dcc9de6c27ecbbfc0e2079fb64b42bad5f Mon Sep 17 00:00:00 2001
2 From: Anton Blanchard <anton@samba.org>
3 Date: Tue, 11 Nov 2014 09:12:28 +1100
4 Subject: powerpc: Fix bad NULL pointer check in udbg_uart_getc_poll()
6 From: Anton Blanchard <anton@samba.org>
8 commit cd32e2dcc9de6c27ecbbfc0e2079fb64b42bad5f upstream.
10 We have some code in udbg_uart_getc_poll() that tries to protect
11 against a NULL udbg_uart_in, but gets it all wrong.
13 Found with the LLVM static analyzer (scan-build).
15 Fixes: 309257484cc1 ("powerpc: Cleanup udbg_16550 and add support for LPC PIO-only UARTs")
16 Signed-off-by: Anton Blanchard <anton@samba.org>
17 [mpe: Add some newlines for readability while we're here]
18 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 arch/powerpc/kernel/udbg_16550.c | 6 +++++-
23 1 file changed, 5 insertions(+), 1 deletion(-)
25 --- a/arch/powerpc/kernel/udbg_16550.c
26 +++ b/arch/powerpc/kernel/udbg_16550.c
27 @@ -69,8 +69,12 @@ static void udbg_uart_putc(char c)
29 static int udbg_uart_getc_poll(void)
31 - if (!udbg_uart_in || !(udbg_uart_in(UART_LSR) & LSR_DR))
35 + if (!(udbg_uart_in(UART_LSR) & LSR_DR))
36 return udbg_uart_in(UART_RBR);