[PATCH] gpio: rockchip: Fix debounce clock leak in rockchip_get_bank_data()
From: Wentao Liang
Date: Wed Sep 16 2026 - 06:30:39 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
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