gpio: rockchip: Fix debounce clock leak in rockchip_get_bank_data()
Subsystems (3)
PATCH 1/1 gpio: rockchip: Fix debounce clock leak in rockchip_get_bank_data()
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")
Signed-off-by Wentao Liang <[email protected]>
--- drivers/gpio/gpio-rockchip.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpio/gpio-rockchip.c +4 -0
@@ -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[] = {
Signature · 1 line
2.34.1