mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
rtc: ftrtc010: fix clock resource leak on probe failure
When devm_rtc_register_device() fails, ftrtc010_rtc_probe() returns
the error directly without releasing clocks obtained via
clk_prepare_enable(). This leaks both extclk and pclk resources,
which may prevent subsequent probe attempts or module removal.
Capture the return value and jump to the error handling path to
properly release clocks via clk_disable_unprepare().
Fixes smatch warnings:
- drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn:
'rtc->extclk' from clk_prepare_enable() not released on lines: 183.
- drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn:
'rtc->pclk' from clk_prepare_enable() not released on lines: 183.
Fixes: fdcfd85433 ("rtc: rework rtc_register_device() resource management")
Assisted-by: smatch:2.0 [static analysis]
Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Tested-by: Liu Dalin <liudalin@kylinsec.com.cn>
Link: https://patch.msgid.link/AC51B5F2C5FFEBB0+20260827080320.3351155-2-liudalin@kylinsec.com.cn
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
cb8a624923
commit
c60478875a
|
|
@ -180,7 +180,11 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)
|
|||
if (unlikely(ret))
|
||||
goto err_disable_extclk;
|
||||
|
||||
return devm_rtc_register_device(rtc_dev);
|
||||
ret = devm_rtc_register_device(rtc_dev);
|
||||
if (ret)
|
||||
goto err_disable_extclk;
|
||||
|
||||
return 0;
|
||||
|
||||
err_disable_extclk:
|
||||
clk_disable_unprepare(rtc->extclk);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user