* [PATCH] pinctrl: stm32: Fix clock reference leak in stm32_pctl_probe()
@ 2026-09-17 13:50 Wentao Liang
2026-09-30 13:17 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 13:50 UTC (permalink / raw)
To: alexandre.torgue
Cc: antonio.borneo, jiashengjiangcool, linusw, linux-arm-kernel,
linux-gpio, linux-kernel, linux-stm32, mcoquelin.stm32, zmw12306,
Wentao Liang, stable
stm32_pctl_probe() obtains one clock per bank with
of_clk_get_by_name(), but none of the error paths drop those
references: the loop returns directly when a later clock lookup fails,
and both the clk_bulk_prepare_enable() failure and the err_register
path return without calling clk_bulk_put(). clk_bulk_disable_unprepare()
only disables the clocks, it does not release them.
Release the references on these paths; the success path keeps them as
the driver needs them for suspend/resume.
Fixes: 451bc9aea9a1 ("pinctrl: stm32: Add check for clk_enable()")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/pinctrl/stm32/pinctrl-stm32.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 6a99708a5a23..587dbf1512dc 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -1976,6 +1976,7 @@ int stm32_pctl_probe(struct platform_device *pdev)
pctl->clks[i].clk = of_clk_get_by_name(np, NULL);
if (IS_ERR(pctl->clks[i].clk)) {
fwnode_handle_put(child);
+ clk_bulk_put(i, pctl->clks);
return dev_err_probe(dev, PTR_ERR(pctl->clks[i].clk),
"failed to get clk\n");
}
@@ -1986,6 +1987,7 @@ int stm32_pctl_probe(struct platform_device *pdev)
ret = clk_bulk_prepare_enable(banks, pctl->clks);
if (ret) {
dev_err(dev, "failed to prepare_enable clk (%d)\n", ret);
+ clk_bulk_put(banks, pctl->clks);
return ret;
}
@@ -2010,6 +2012,7 @@ int stm32_pctl_probe(struct platform_device *pdev)
}
clk_bulk_disable_unprepare(banks, pctl->clks);
+ clk_bulk_put(banks, pctl->clks);
return ret;
}
EXPORT_SYMBOL(stm32_pctl_probe);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] pinctrl: stm32: Fix clock reference leak in stm32_pctl_probe()
2026-09-17 13:50 [PATCH] pinctrl: stm32: Fix clock reference leak in stm32_pctl_probe() Wentao Liang
@ 2026-09-30 13:17 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2026-09-30 13:17 UTC (permalink / raw)
To: Wentao Liang
Cc: alexandre.torgue, antonio.borneo, jiashengjiangcool,
linux-arm-kernel, linux-gpio, linux-kernel, linux-stm32,
mcoquelin.stm32, zmw12306, stable
On Thu, Sep 17, 2026 at 3:50 PM Wentao Liang <vulab@iscas.ac.cn> wrote:
> stm32_pctl_probe() obtains one clock per bank with
> of_clk_get_by_name(), but none of the error paths drop those
> references: the loop returns directly when a later clock lookup fails,
> and both the clk_bulk_prepare_enable() failure and the err_register
> path return without calling clk_bulk_put(). clk_bulk_disable_unprepare()
> only disables the clocks, it does not release them.
>
> Release the references on these paths; the success path keeps them as
> the driver needs them for suspend/resume.
>
> Fixes: 451bc9aea9a1 ("pinctrl: stm32: Add check for clk_enable()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Patch applied w/o stale tag.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-30 13:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 13:50 [PATCH] pinctrl: stm32: Fix clock reference leak in stm32_pctl_probe() Wentao Liang
2026-09-30 13:17 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®