]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.3/powerpc-fix-bad-null-pointer-check-in-udbg_uart_getc_poll.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 3.18.3 / powerpc-fix-bad-null-pointer-check-in-udbg_uart_getc_poll.patch
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()
5
6 From: Anton Blanchard <anton@samba.org>
7
8 commit cd32e2dcc9de6c27ecbbfc0e2079fb64b42bad5f upstream.
9
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.
12
13 Found with the LLVM static analyzer (scan-build).
14
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>
20
21 ---
22 arch/powerpc/kernel/udbg_16550.c | 6 +++++-
23 1 file changed, 5 insertions(+), 1 deletion(-)
24
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)
28
29 static int udbg_uart_getc_poll(void)
30 {
31 - if (!udbg_uart_in || !(udbg_uart_in(UART_LSR) & LSR_DR))
32 + if (!udbg_uart_in)
33 + return -1;
34 +
35 + if (!(udbg_uart_in(UART_LSR) & LSR_DR))
36 return udbg_uart_in(UART_RBR);
37 +
38 return -1;
39 }
40