Re: [PATCH] platform/chrome: fix reference leak on failed device registration

From: Guangshuo Li

Date: Fri Apr 24 2026 - 04:33:49 EST


Hi Olof, all,

Just to follow up: please disregard this patch.

On Thu, 16 Apr 2026 at 18:21, Guangshuo Li <lgs201920130244@xxxxxxxxx> wrote:
>
> 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

After re-checking it, chromeos_ramoops is a static platform_device and it
does not provide a dev.release callback. Therefore calling
platform_device_put() on the platform_device_register() failure path is
not appropriate here and can trigger the missing release callback
warning.

This falls into the same static platform_device pattern pointed out in
the other reviews. Also, as Olof noted, this version does not compile due
to the missing ret declaration.

I will drop this patch.

Sorry for the noise.

Best regards,
Guangshuo Li