From: Wentao Liang <vulab@iscas.ac.cn>
To: andriy.shevchenko@linux.intel.com
Cc: brgl@kernel.org, heiko@sntech.de, linusw@kernel.org,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
sebastian.reichel@collabora.com, ye.zhang@rock-chips.com,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] gpio: rockchip: Fix bank clock leak in rockchip_get_bank_data()
Date: Wed, 16 Sep 2026 10:22:58 +0000 [thread overview]
Message-ID: <20260916102258.2018689-1-vulab@iscas.ac.cn> (raw)
rockchip_get_bank_data() obtains the bank clock with of_clk_get() and
enables it before reading the GPIO version ID. The reference returned
by of_clk_get() is never dropped on the error paths that follow:
When the debounce clock is missing, the bank clock is disabled with
clk_disable_unprepare() but the reference is never released with
clk_put(). When the version ID is unsupported, the function returns
-ENODEV leaving the bank clock prepared, enabled and referenced.
Drop the reference with clk_put() on both error paths and disable and
unprepare the bank clock on the unsupported version path so that probe
failures no longer leak the clock.
Fixes: 41209307cad7 ("gpio: rockchip: change the GPIO version judgment logic")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/gpio/gpio-rockchip.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index 44d7ebd12724..69a7cd8c9a1a 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -673,6 +673,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
if (IS_ERR(bank->db_clk)) {
dev_err(bank->dev, "cannot find debounce clk\n");
clk_disable_unprepare(bank->clk);
+ clk_put(bank->clk);
return -EINVAL;
}
break;
@@ -682,6 +683,8 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
break;
default:
dev_err(bank->dev, "unsupported version ID: 0x%08x\n", id);
+ clk_disable_unprepare(bank->clk);
+ clk_put(bank->clk);
return -ENODEV;
}
--
2.34.1
next reply other threads:[~2026-09-16 10:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 10:22 Wentao Liang [this message]
2026-09-16 10:55 ` Sebastian Reichel
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=20260916102258.2018689-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brgl@kernel.org \
--cc=heiko@sntech.de \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=sebastian.reichel@collabora.com \
--cc=stable@vger.kernel.org \
--cc=ye.zhang@rock-chips.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
all inboxes | Powered by JetHome®