Re: [PATCH] MIPS: ralink: Fix refcount leak in ill_acc_of_setup()
From: Thorsten Blum
Date: Wed Apr 09 2025 - 10:18:08 EST
On 9. Apr 2025, at 14:57, Jonas Gorski wrote:
> On Mon, Apr 7, 2025 at 10:32 AM Thorsten Blum wrote:
>>
>> The of_find_device_by_node() function increments the reference count of
>> the embedded device, which should be released with put_device() when it
>> is no longer needed.
>>
>> In ill_acc_of_setup(), put_device() is only called on error paths, but
>> not on the success path. Fix this by calling put_device() before
>> returning successfully.
>
> I would think this is very much deliberate as the device is used as
> the priv argument of the registered IRQ handler. AFAIU as long as that
> one is live the reference of the device needs to be kept.
>
> Dropping the reference of the device should only be done after
> freeing/unregistering the IRQ again, which currently never happens.
Thanks for the explanation. I assumed request_irq() would increment the
refcount, but that's apparently not the case because it's just a cookie.
Thanks,
Thorsten