Skip to content

Commit b520cbe

Browse files
Yuuoniyalexandrebelloni
authored andcommitted
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: ac05fba ("rtc: gemini: Add optional clock handling") Signed-off-by: Miaoqian Lin <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d3b43eb commit b520cbe

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

drivers/rtc/rtc-ftrtc010.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,34 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)
137137
ret = clk_prepare_enable(rtc->extclk);
138138
if (ret) {
139139
dev_err(dev, "failed to enable EXTCLK\n");
140-
return ret;
140+
goto err_disable_pclk;
141141
}
142142
}
143143

144144
rtc->rtc_irq = platform_get_irq(pdev, 0);
145-
if (rtc->rtc_irq < 0)
146-
return rtc->rtc_irq;
145+
if (rtc->rtc_irq < 0) {
146+
ret = rtc->rtc_irq;
147+
goto err_disable_extclk;
148+
}
147149

148150
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
149-
if (!res)
150-
return -ENODEV;
151+
if (!res) {
152+
ret = -ENODEV;
153+
goto err_disable_extclk;
154+
}
151155

152156
rtc->rtc_base = devm_ioremap(dev, res->start,
153157
resource_size(res));
154-
if (!rtc->rtc_base)
155-
return -ENOMEM;
158+
if (!rtc->rtc_base) {
159+
ret = -ENOMEM;
160+
goto err_disable_extclk;
161+
}
156162

157163
rtc->rtc_dev = devm_rtc_allocate_device(dev);
158-
if (IS_ERR(rtc->rtc_dev))
159-
return PTR_ERR(rtc->rtc_dev);
164+
if (IS_ERR(rtc->rtc_dev)) {
165+
ret = PTR_ERR(rtc->rtc_dev);
166+
goto err_disable_extclk;
167+
}
160168

161169
rtc->rtc_dev->ops = &ftrtc010_rtc_ops;
162170

@@ -172,9 +180,15 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)
172180
ret = devm_request_irq(dev, rtc->rtc_irq, ftrtc010_rtc_interrupt,
173181
IRQF_SHARED, pdev->name, dev);
174182
if (unlikely(ret))
175-
return ret;
183+
goto err_disable_extclk;
176184

177185
return devm_rtc_register_device(rtc->rtc_dev);
186+
187+
err_disable_extclk:
188+
clk_disable_unprepare(rtc->extclk);
189+
err_disable_pclk:
190+
clk_disable_unprepare(rtc->pclk);
191+
return ret;
178192
}
179193

180194
static int ftrtc010_rtc_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)