aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/sccnxp.c
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2017-09-02 16:13:55 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-09-18 12:19:21 -0400
commitc91261437985d481c472639d4397931d77f5d4e9 (patch)
tree0f729a21dcc74c6abb0e6a7bd472d6b461d7bd5c /drivers/tty/serial/sccnxp.c
parent9d7ee0e28da59b05647c3d2a7ad4076c16b1a6ef (diff)
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>
Diffstat (limited to 'drivers/tty/serial/sccnxp.c')
-rw-r--r--drivers/tty/serial/sccnxp.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index cdd2f942317c..b9c7a904c1ea 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -889,7 +889,16 @@ static int sccnxp_probe(struct platform_device *pdev)
889 goto err_out; 889 goto err_out;
890 uartclk = 0; 890 uartclk = 0;
891 } else { 891 } 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
893 uartclk = clk_get_rate(clk); 902 uartclk = clk_get_rate(clk);
894 } 903 }
895 904
@@ -988,7 +997,7 @@ static int sccnxp_probe(struct platform_device *pdev)
988 uart_unregister_driver(&s->uart); 997 uart_unregister_driver(&s->uart);
989err_out: 998err_out:
990 if (!IS_ERR(s->regulator)) 999 if (!IS_ERR(s->regulator))
991 return regulator_disable(s->regulator); 1000 regulator_disable(s->regulator);
992 1001
993 return ret; 1002 return ret;
994} 1003}