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

From: Olof Johansson

Date: Wed Apr 15 2026 - 17:47:49 EST


On Wed, Apr 15, 2026 at 10:50 AM Guangshuo Li <lgs201920130244@xxxxxxxxx> wrote:
>
> When platform_device_register() fails in chromeos_pstore_init(), the
> embedded struct device in chromeos_ramoops has already been initialized
> by device_initialize(), but the failure path returns the error without
> dropping the device reference for the current platform device:
>
> chromeos_pstore_init()
> -> platform_device_register(&chromeos_ramoops)
> -> device_initialize(&chromeos_ramoops.dev)
> -> setup_pdev_dma_masks(&chromeos_ramoops)
> -> platform_device_add(&chromeos_ramoops)
>
> This leads to a reference leak when platform_device_register() fails.
> Fix this by calling platform_device_put() before returning the error.
>
> The issue was identified by a static analysis tool I developed and
> confirmed by manual review.
>
> Fixes: 9742e127cd0dd ("platform/chrome: Add pstore platform_device")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>

This looks like slop to me. It doesn't even compile (there's no local
'ret' variable in the function already).

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