[PATCH] clocksource/drivers/digicolor: Fix clk reference leak on request_irq failure

Wentao Liang posted 1 patch 1 week, 3 days ago
drivers/clocksource/timer-digicolor.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] clocksource/drivers/digicolor: Fix clk reference leak on request_irq failure
Posted by Wentao Liang 1 week, 3 days ago
digicolor_timer_init() obtains the timer clock with of_clk_get() and
enables it, but the request_irq() failure path returns without releasing
the clock reference, leaking both the enable/prepare state and the
reference itself.

Disable and put the clock before returning on the request_irq() failure
path. The success path keeps the clock enabled for the lifetime of the
timer and is left untouched.

Fixes: 9b8bb7736b78 ("clocksource: Driver for Conexant Digicolor SoC timer")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/clocksource/timer-digicolor.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clocksource/timer-digicolor.c b/drivers/clocksource/timer-digicolor.c
index 559aa96089c3..46e0c329957a 100644
--- a/drivers/clocksource/timer-digicolor.c
+++ b/drivers/clocksource/timer-digicolor.c
@@ -190,6 +190,8 @@ static int __init digicolor_timer_init(struct device_node *node)
 			  &dc_timer_dev.ce);
 	if (ret) {
 		pr_warn("request of timer irq %d failed (%d)\n", irq, ret);
+		clk_disable_unprepare(clk);
+		clk_put(clk);
 		return ret;
 	}
 
-- 
2.34.1
Re: [PATCH] clocksource/drivers/digicolor: Fix clk reference leak on request_irq failure
Posted by Baruch Siach 1 week, 2 days ago
Hi Wentao Liang,

On Tue, Sep 15 2026, Wentao Liang wrote:
> digicolor_timer_init() obtains the timer clock with of_clk_get() and
> enables it, but the request_irq() failure path returns without releasing
> the clock reference, leaking both the enable/prepare state and the
> reference itself.
>
> Disable and put the clock before returning on the request_irq() failure
> path. The success path keeps the clock enabled for the lifetime of the
> timer and is left untouched.
>
> Fixes: 9b8bb7736b78 ("clocksource: Driver for Conexant Digicolor SoC timer")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

Acked-by: Baruch Siach <baruch@tkos.co.il>

Thanks,
baruch

> ---
>  drivers/clocksource/timer-digicolor.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/clocksource/timer-digicolor.c b/drivers/clocksource/timer-digicolor.c
> index 559aa96089c3..46e0c329957a 100644
> --- a/drivers/clocksource/timer-digicolor.c
> +++ b/drivers/clocksource/timer-digicolor.c
> @@ -190,6 +190,8 @@ static int __init digicolor_timer_init(struct device_node *node)
>  			  &dc_timer_dev.ce);
>  	if (ret) {
>  		pr_warn("request of timer irq %d failed (%d)\n", irq, ret);
> +		clk_disable_unprepare(clk);
> +		clk_put(clk);
>  		return ret;
>  	}

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -