rtc: brcmstb-waketimer: fix error handling in brcmstb_waketmr_probe()
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Fri, 17 Nov 2017 21:15:58 +0000 (00:15 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Mar 2018 07:42:49 +0000 (08:42 +0100)
[ Upstream commit f2eef045de9defbc6fc6b72b17f0941cbe26c81d ]

brcmstb_waketmr_probe() does not disable timer->clk on error paths.

Found by Linux Driver Verification project (linuxtesting.org).

Fixes: c4f07ecee22e ("rtc: brcmstb-waketimer: Add Broadcom STB wake-timer")
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/rtc/rtc-brcmstb-waketimer.c

index 796ac792a381f4e0e8ecaeb7667a5180e2d9b843..6cee61201c30cb4a15eef3fbd72a7df57313e04b 100644 (file)
@@ -253,7 +253,7 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev)
        ret = devm_request_irq(dev, timer->irq, brcmstb_waketmr_irq, 0,
                               "brcmstb-waketimer", timer);
        if (ret < 0)
-               return ret;
+               goto err_clk;
 
        timer->reboot_notifier.notifier_call = brcmstb_waketmr_reboot;
        register_reboot_notifier(&timer->reboot_notifier);
@@ -262,12 +262,21 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev)
                                         &brcmstb_waketmr_ops, THIS_MODULE);
        if (IS_ERR(timer->rtc)) {
                dev_err(dev, "unable to register device\n");
-               unregister_reboot_notifier(&timer->reboot_notifier);
-               return PTR_ERR(timer->rtc);
+               ret = PTR_ERR(timer->rtc);
+               goto err_notifier;
        }
 
        dev_info(dev, "registered, with irq %d\n", timer->irq);
 
+       return 0;
+
+err_notifier:
+       unregister_reboot_notifier(&timer->reboot_notifier);
+
+err_clk:
+       if (timer->clk)
+               clk_disable_unprepare(timer->clk);
+
        return ret;
 }