Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: rockchip: Fix debounce clock leak in rockchip_get_bank_data()
@ 2026-09-16 10:25 Wentao Liang
  0 siblings, 0 replies; only message in thread
From: Wentao Liang @ 2026-09-16 10:25 UTC (permalink / raw)
  To: brgl
  Cc: heiko, jay.xu, linusw, linux-arm-kernel, linux-gpio, linux-kernel,
	linux-rockchip, Wentao Liang, stable

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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-16 10:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16 10:25 [PATCH] gpio: rockchip: Fix debounce clock leak in rockchip_get_bank_data() Wentao Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox