* [PATCH] gpio: rockchip: Fix bank clock leak in rockchip_get_bank_data()
@ 2026-09-16 10:22 Wentao Liang
2026-09-16 10:55 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16 10:22 UTC (permalink / raw)
To: andriy.shevchenko
Cc: brgl, heiko, linusw, linux-arm-kernel, linux-gpio, linux-kernel,
linux-rockchip, sebastian.reichel, ye.zhang, Wentao Liang,
stable
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: rockchip: Fix bank clock leak in rockchip_get_bank_data()
2026-09-16 10:22 [PATCH] gpio: rockchip: Fix bank clock leak in rockchip_get_bank_data() Wentao Liang
@ 2026-09-16 10:55 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2026-09-16 10:55 UTC (permalink / raw)
To: Wentao Liang
Cc: andriy.shevchenko, brgl, heiko, linusw, linux-arm-kernel,
linux-gpio, linux-kernel, linux-rockchip, ye.zhang, stable
[-- Attachment #1: Type: text/plain, Size: 2059 bytes --]
Hi,
On Wed, Sep 16, 2026 at 10:22:58AM +0000, Wentao Liang wrote:
> 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>
> ---
This got fixed in 3e46c18d5d87 ("gpio: rockchip: convert bank->clk
to devm_clk_get_enabled()") and 950007767823 ("gpio: rockchip:
teardown bugs and resource leaks") already. Please make sure to use
latest kernel trees.
Greetings,
-- Sebastian
> 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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-16 10:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 10:22 [PATCH] gpio: rockchip: Fix bank clock leak in rockchip_get_bank_data() Wentao Liang
2026-09-16 10:55 ` Sebastian Reichel
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®