From: Wentao Liang <vulab@iscas.ac.cn>
To: linusw@kernel.org
Cc: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, schung@nuvoton.com,
ychuang3@nuvoton.com, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] pinctrl: nuvoton: Fix clock reference leak in ma35_get_bank_data()
Date: Thu, 17 Sep 2026 13:48:11 +0000 [thread overview]
Message-ID: <20260917134811.2153902-1-vulab@iscas.ac.cn> (raw)
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
next reply other threads:[~2026-09-17 13:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 13:48 Wentao Liang [this message]
2026-09-30 13:16 ` [PATCH] pinctrl: nuvoton: Fix clock reference leak in ma35_get_bank_data() Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260917134811.2153902-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=schung@nuvoton.com \
--cc=stable@vger.kernel.org \
--cc=ychuang3@nuvoton.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox