Skip to content

Commit c912614

Browse files
khoroshilovgregkh
authored andcommitted
serial: sccnxp: Fix error handling in sccnxp_probe()
sccnxp_probe() returns result of regulator_disable() that may lead to returning zero, while device is not properly initialized. Also the driver enables clocks, but it does not disable it. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9d7ee0e commit c912614

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/tty/serial/sccnxp.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,16 @@ static int sccnxp_probe(struct platform_device *pdev)
889889
goto err_out;
890890
uartclk = 0;
891891
} else {
892-
clk_prepare_enable(clk);
892+
ret = clk_prepare_enable(clk);
893+
if (ret)
894+
goto err_out;
895+
896+
ret = devm_add_action_or_reset(&pdev->dev,
897+
(void(*)(void *))clk_disable_unprepare,
898+
clk);
899+
if (ret)
900+
goto err_out;
901+
893902
uartclk = clk_get_rate(clk);
894903
}
895904

@@ -988,7 +997,7 @@ static int sccnxp_probe(struct platform_device *pdev)
988997
uart_unregister_driver(&s->uart);
989998
err_out:
990999
if (!IS_ERR(s->regulator))
991-
return regulator_disable(s->regulator);
1000+
regulator_disable(s->regulator);
9921001

9931002
return ret;
9941003
}

0 commit comments

Comments
 (0)