serial-uartlite: fix null pointer dereference on pointer port
authorColin Ian King <colin.king@canonical.com>
Tue, 13 Nov 2018 09:43:23 +0000 (09:43 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Nov 2018 08:08:15 +0000 (09:08 +0100)
commitee0a29ba574bde9861eee08d7b13a9cfbfcc8d1f
treefbe76fa2fbb95f0f1f06fbc6c2cd0b36c12bc08f
parentd491324f966518fbd3f4c627a3e9766d018a4eef
serial-uartlite: fix null pointer dereference on pointer port

Pointer port is dereferenced on port->private_data when assigning pointer
pdata before port is null checked, leading to a potential null pointer
dereference.  Fix this by assigning pdata after the null pointer check on
port.

Detected by CoverityScan, CID#1475434 ("Dereference before null check")

Fixes: 3b209d253e7f ("serial-uartlite: Do not use static struct uart_driver out of probe()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/uartlite.c