mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pinctrl: nuvoton: Fix clock reference leak in ma35_get_bank_data()
@ 2026-09-17 13:48 Wentao Liang
  2026-09-30 13:16 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 13:48 UTC (permalink / raw)
  To: linusw
  Cc: linux-arm-kernel, linux-gpio, linux-kernel, schung, ychuang3,
	Wentao Liang, stable

ma35_get_bank_data() obtains the bank clock with of_clk_get() and
stores it in bank->clk, but returns clk_prepare_enable() directly.  If
that call fails, the reference taken by of_clk_get() is never dropped,
and the driver has no other clk_put() for it.

Drop the reference when clk_prepare_enable() fails.

Fixes: f805e356313b ("pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/pinctrl/nuvoton/pinctrl-ma35.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
index f01344201628..c94c4adb2125 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c
@@ -557,6 +557,8 @@ static int ma35_gpiolib_register(struct platform_device *pdev, struct ma35_pinct
 
 static int ma35_get_bank_data(struct ma35_pin_bank *bank)
 {
+	int ret;
+
 	bank->reg_base = fwnode_iomap(bank->fwnode, 0);
 	if (!bank->reg_base)
 		return -ENOMEM;
@@ -569,7 +571,11 @@ static int ma35_get_bank_data(struct ma35_pin_bank *bank)
 	if (IS_ERR(bank->clk))
 		return PTR_ERR(bank->clk);
 
-	return clk_prepare_enable(bank->clk);
+	ret = clk_prepare_enable(bank->clk);
+	if (ret)
+		clk_put(bank->clk);
+
+	return ret;
 }
 
 static int ma35_pinctrl_get_soc_data(struct ma35_pinctrl *pctl, struct platform_device *pdev)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] pinctrl: nuvoton: Fix clock reference leak in ma35_get_bank_data()
  2026-09-17 13:48 [PATCH] pinctrl: nuvoton: Fix clock reference leak in ma35_get_bank_data() Wentao Liang
@ 2026-09-30 13:16 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2026-09-30 13:16 UTC (permalink / raw)
  To: Wentao Liang
  Cc: linux-arm-kernel, linux-gpio, linux-kernel, schung, ychuang3, stable

On Thu, Sep 17, 2026 at 3:48 PM Wentao Liang <vulab@iscas.ac.cn> wrote:

> ma35_get_bank_data() obtains the bank clock with of_clk_get() and
> stores it in bank->clk, but returns clk_prepare_enable() directly.  If
> that call fails, the reference taken by of_clk_get() is never dropped,
> and the driver has no other clk_put() for it.
>
> Drop the reference when clk_prepare_enable() fails.
>
> Fixes: f805e356313b ("pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

Patch applied. I dropped stable because it's not that serious.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-30 13:16 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:48 [PATCH] pinctrl: nuvoton: Fix clock reference leak in ma35_get_bank_data() Wentao Liang
2026-09-30 13:16 ` 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®