Re: [PATCH] platform/chrome: fix reference leak on failed device registration
From: Guangshuo Li
Date: Thu Apr 16 2026 - 06:24:38 EST
Hi Olof,
Thanks.
On Thu, 16 Apr 2026 at 17:26, Guangshuo Li <lgs201920130244@xxxxxxxxx> wrote:
>
> Hi Olof,
>
> Thanks for the review.
>
> On Thu, 16 Apr 2026 at 05:47, Olof Johansson <olof@xxxxxxxxx> wrote:
> >
> >
> > This looks like slop to me. It doesn't even compile (there's no local
> > 'ret' variable in the function already).
>
> You're right, I missed declaring the local ret variable in this
> version, so it does not compile. Sorry for that mistake.
>
> > This is also a no-value fix, the chromeos_ramoops structure is static
> > data and not dynamically allocated. Please don't burden maintainers
> > with these kinds of "fixes".
> >
> >
> > -Olof
>
> My reasoning was based on the implementation of
> platform_device_register(): it calls device_initialize(), but if
> platform_device_add() fails, platform_device_register() returns the
> error directly without dropping the device reference initialized there.
> Based on that, I thought the caller might need to release that
> reference.
>
> That said, I understand your point that for this statically defined
> chromeos_ramoops device this is not a useful fix.
>
> Thanks,
> Guangshuo
We are also discussing in another similar patch whether the
better fix, if any, should be in the API/core code rather than in
individual callers:
https://patchew.org/linux/20260415174159.3625777-1-lgs201920130244@xxxxxxxxx/
Thanks,
Guangshuo