From: Wentao Liang <vulab@iscas.ac.cn>
To: brgl@kernel.org
Cc: heiko@sntech.de, jay.xu@rock-chips.com, linusw@kernel.org,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] gpio: rockchip: Fix debounce clock leak in rockchip_get_bank_data()
Date: Wed, 16 Sep 2026 10:25:29 +0000 [thread overview]
Message-ID: <20260916102529.2019277-1-vulab@iscas.ac.cn> (raw)
rockchip_get_bank_data() obtains the debounce clock with of_clk_get()
for GPIO v2 banks and stores it in bank->db_clk for later use by the
debounce handling, but the reference is never released anywhere in the
driver. When rockchip_gpiolib_register() fails in rockchip_gpio_probe()
or when the device unbinds, the debounce clock reference leaks.
Release the references returned by of_clk_get() with clk_put() when
probe fails after the gpiochip registration and when the device is
removed. The bank clock reference is dropped as well since it suffers
from the same problem.
Fixes: 3bcbd1a85b68 ("gpio/rockchip: support next version gpio controller")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/gpio/gpio-rockchip.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index 69a7cd8c9a1a..cab1ac78c48f 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -755,6 +755,8 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
ret = rockchip_gpiolib_register(bank);
if (ret) {
clk_disable_unprepare(bank->clk);
+ clk_put(bank->clk);
+ clk_put(bank->db_clk);
mutex_unlock(&bank->deferred_lock);
return ret;
}
@@ -797,6 +799,8 @@ static void rockchip_gpio_remove(struct platform_device *pdev)
clk_disable_unprepare(bank->clk);
gpiochip_remove(&bank->gpio_chip);
+ clk_put(bank->clk);
+ clk_put(bank->db_clk);
}
static const struct of_device_id rockchip_gpio_match[] = {
--
2.34.1
reply other threads:[~2026-09-16 10:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260916102529.2019277-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=brgl@kernel.org \
--cc=heiko@sntech.de \
--cc=jay.xu@rock-chips.com \
--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=stable@vger.kernel.org \
/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