uart: fix NULL pointer deferencing in suspend/resume

PD#151229: driver defect clean up
#235
#236

Change-Id: I59acc448a4ece1f385d0b6d602721d34ce60e02c
Signed-off-by: Jiamin Ma <jiamin.ma@amlogic.com>
This commit is contained in:
Jiamin Ma
2017-09-20 14:54:31 +08:00
committed by Jianxin Pan
parent cc619fdedb
commit 0385280d28

View File

@@ -1150,12 +1150,15 @@ static int meson_uart_resume(struct platform_device *pdev)
u32 val;
port = platform_get_drvdata(pdev);
if (port) {
if (port->line == 0)
return 0;
uart_resume_port(&meson_uart_driver, port);
if (!port) {
dev_err(&pdev->dev, "port is NULL");
return 0;
}
if (port->line == 0)
return 0;
uart_resume_port(&meson_uart_driver, port);
val = readl(port->membase + AML_UART_CONTROL);
if (!(val & AML_UART_TWO_WIRE_EN)) {
val &= ~(0x1 << 31);
@@ -1172,11 +1175,15 @@ static int meson_uart_suspend(struct platform_device *pdev,
u32 val;
port = platform_get_drvdata(pdev);
if (port) {
if (port->line == 0)
return 0;
uart_suspend_port(&meson_uart_driver, port);
if (!port) {
dev_err(&pdev->dev, "port is NULL");
return 0;
}
if (port->line == 0)
return 0;
uart_suspend_port(&meson_uart_driver, port);
val = readl(port->membase + AML_UART_CONTROL);
/* if rts/cts is open, pull up rts pin
* when in suspend