Re: [PATCH] soc: mediatek: SVS: fix device reference leak in svs_add_device_link()
From: Coia Prant
Date: Sun Oct 25 2026 - 04:46:52 EST
On October 25, 2026 3:58:06 PM GMT+08:00, Markus Elfring <Markus.Elfring@xxxxxx> wrote:
>…
>> Drop the reference before returning on both paths.
>…
>
>How do you think about to increase the application of scope-based resource management?
>https://elixir.bootlin.com/linux/v7.3/source/include/linux/device.h#L1363
>
>Regards,
>Markus
Hi Markus,
Thanks for the suggestion. To be upfront: I'm not the maintainer of this
driver, I just ran into the leak while reading through the code and
wanted to send a minimal fix.
__free(), DEFINE_FREE() and return_ptr() only appeared in v6.5, while
this driver dates back to v5.19 and the fix is tagged for stable (first
LTS is v6.1). Converting to scope-based cleanup here would not compile
on 6.1.y and would force the stable team to rewrite the backport.
So I'd prefer to keep the explicit put_device() in this patch and leave
the __free(put_device) conversion to whoever owns the driver, as a
separate cleanup when the stable backport is no longer a concern.
Regards,
Coia