Skip to content

Commit

Permalink
uart: fix NULL pointer deferencing in suspend/resume
Browse files Browse the repository at this point in the history
PD#151229: driver defect clean up
torvalds#235
torvalds#236

Change-Id: I59acc448a4ece1f385d0b6d602721d34ce60e02c
Signed-off-by: Jiamin Ma <[email protected]>
  • Loading branch information
Jiamin Ma authored and akiernan committed Nov 4, 2022
1 parent 38bbff9 commit 57fb738
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions drivers/amlogic/uart/meson_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit 57fb738

Please sign in to comment.