Re: [PATCH 4/6] clocksource/drivers/davinci: Fix clock reference leak in of_davinci_timer_register

From: Bartosz Golaszewski

Date: Tue Sep 15 2026 - 06:13:21 EST


On Tue, 15 Sep 2026 11:25:18 +0200, Wentao Liang <vulab@xxxxxxxxxxx> said:
> On Tue, 15 Sep 2026 07:55:06 +0200, Bartosz Golaszewski <brgl@xxxxxxxxxx> said:
>> I'm not following. If we keep the clock enabled, we must keep the reference. We
>> just never disable it anywhere, so you correctly don't see the clk_put() in
>> success path.
>
> Hi Bart,
>
> Thanks for taking a look. Let me clarify the point about ownership:
> prepare/enable state is tracked on struct clk_core and is orthogonal to
> the consumer reference. clk_put() merely unlinks the consumer and drops
> the kref on the core clock (see __clk_put() in drivers/clk/clk.c) -- it
> neither disables nor unprepares the clock. So releasing the reference
> does not change the clock's state; the timer clock stays enabled for the
> lifetime of the system either way. This is the same reasoning used by
> callers that enable a clock and then put the consumer handle.
>
> That said, I do understand the convention for these early boot timers
> that are never disabled -- dw_apb_timer_of, timer-owl and asm9260_timer
> also keep (or simply never put) the reference on success. If you consider
> the reference intentionally retained as a subsystem convention, I'm fine
> with dropping this patch; alternatively I could send a version that only
> adds a comment documenting the intent. Please let me know which you
> prefer.
>

Can you test it on real hardware? I still have a davinci board somewhere but
I haven't booted it in years. If you can test it, I'm fine with it, otherwise,
I'd leave it as is just to be sure.

Bartosz