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 <khoroshilov@ispras.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9d7ee0e28d
commit
c912614379
|
@ -889,7 +889,16 @@ static int sccnxp_probe(struct platform_device *pdev)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
uartclk = 0;
|
uartclk = 0;
|
||||||
} else {
|
} else {
|
||||||
clk_prepare_enable(clk);
|
ret = clk_prepare_enable(clk);
|
||||||
|
if (ret)
|
||||||
|
goto err_out;
|
||||||
|
|
||||||
|
ret = devm_add_action_or_reset(&pdev->dev,
|
||||||
|
(void(*)(void *))clk_disable_unprepare,
|
||||||
|
clk);
|
||||||
|
if (ret)
|
||||||
|
goto err_out;
|
||||||
|
|
||||||
uartclk = clk_get_rate(clk);
|
uartclk = clk_get_rate(clk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,7 +997,7 @@ static int sccnxp_probe(struct platform_device *pdev)
|
||||||
uart_unregister_driver(&s->uart);
|
uart_unregister_driver(&s->uart);
|
||||||
err_out:
|
err_out:
|
||||||
if (!IS_ERR(s->regulator))
|
if (!IS_ERR(s->regulator))
|
||||||
return regulator_disable(s->regulator);
|
regulator_disable(s->regulator);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue