mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
pinctrl: stm32: Fix clock reference leak in stm32_pctl_probe()
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: 451bc9aea9 ("pinctrl: stm32: Add check for clk_enable()")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Signed-off-by: Linus Walleij <linusw@kernel.org>
This commit is contained in:
parent
a854aa8e55
commit
dfd8259507
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user