mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
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: 309257484c
("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>
This commit is contained in:
parent
6609ed14de
commit
cd32e2dcc9
1 changed files with 5 additions and 1 deletions
|
@ -69,8 +69,12 @@ static void udbg_uart_putc(char c)
|
||||||
|
|
||||||
static int udbg_uart_getc_poll(void)
|
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 udbg_uart_in(UART_RBR);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue