Commit b520cbe5 authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Alexandre Belloni

rtc: ftrtc010: Fix error handling in ftrtc010_rtc_probe

In the error handling path, the clk_prepare_enable() function
call should be balanced by a corresponding 'clk_disable_unprepare()'
call , as already done in the remove function.

clk_disable_unprepare calls clk_disable() and clk_unprepare().
They will use IS_ERR_OR_NULL to check the argument.

Fixes: ac05fba3 ("rtc: gemini: Add optional clock handling")
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220403054912.31739-1-linmq006@gmail.com
parent d3b43eb5
...@@ -137,26 +137,34 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev) ...@@ -137,26 +137,34 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)
ret = clk_prepare_enable(rtc->extclk); ret = clk_prepare_enable(rtc->extclk);
if (ret) { if (ret) {
dev_err(dev, "failed to enable EXTCLK\n"); dev_err(dev, "failed to enable EXTCLK\n");
return ret; goto err_disable_pclk;
} }
} }
rtc->rtc_irq = platform_get_irq(pdev, 0); rtc->rtc_irq = platform_get_irq(pdev, 0);
if (rtc->rtc_irq < 0) if (rtc->rtc_irq < 0) {
return rtc->rtc_irq; ret = rtc->rtc_irq;
goto err_disable_extclk;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) if (!res) {
return -ENODEV; ret = -ENODEV;
goto err_disable_extclk;
}
rtc->rtc_base = devm_ioremap(dev, res->start, rtc->rtc_base = devm_ioremap(dev, res->start,
resource_size(res)); resource_size(res));
if (!rtc->rtc_base) if (!rtc->rtc_base) {
return -ENOMEM; ret = -ENOMEM;
goto err_disable_extclk;
}
rtc->rtc_dev = devm_rtc_allocate_device(dev); rtc->rtc_dev = devm_rtc_allocate_device(dev);
if (IS_ERR(rtc->rtc_dev)) if (IS_ERR(rtc->rtc_dev)) {
return PTR_ERR(rtc->rtc_dev); ret = PTR_ERR(rtc->rtc_dev);
goto err_disable_extclk;
}
rtc->rtc_dev->ops = &ftrtc010_rtc_ops; rtc->rtc_dev->ops = &ftrtc010_rtc_ops;
...@@ -172,9 +180,15 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev) ...@@ -172,9 +180,15 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)
ret = devm_request_irq(dev, rtc->rtc_irq, ftrtc010_rtc_interrupt, ret = devm_request_irq(dev, rtc->rtc_irq, ftrtc010_rtc_interrupt,
IRQF_SHARED, pdev->name, dev); IRQF_SHARED, pdev->name, dev);
if (unlikely(ret)) if (unlikely(ret))
return ret; goto err_disable_extclk;
return devm_rtc_register_device(rtc->rtc_dev); return devm_rtc_register_device(rtc->rtc_dev);
err_disable_extclk:
clk_disable_unprepare(rtc->extclk);
err_disable_pclk:
clk_disable_unprepare(rtc->pclk);
return ret;
} }
static int ftrtc010_rtc_remove(struct platform_device *pdev) static int ftrtc010_rtc_remove(struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment