[PATCH] macintosh: windfarm_core: fix reference leak on failed device registration

Guangshuo Li lgs201920130244 at gmail.com
Fri Apr 24 18:14:56 AEST 2026


Hi,

Please disregard this patch.

On Wed, 15 Apr 2026 at 22:46, Guangshuo Li <lgs201920130244 at gmail.com> wrote:
>
> When platform_device_register() fails in windfarm_core_init(), the
> embedded struct device in wf_platform_device has already been
> initialized by device_initialize(), but the failure path does not drop
> the device reference for the current platform device:
>
>   windfarm_core_init()
>     platform_device_register(&wf_platform_device)
>       device_initialize(&wf_platform_device.dev)
>       setup_pdev_dma_masks(&wf_platform_device)
>       return platform_device_add(&wf_platform_device)
>
> This leads to a reference leak when platform_device_register() fails.
> Fix this by checking the return value and calling platform_device_put().
>
> The issue was identified by a static analysis tool I developed and
> confirmed by manual review.
>
> Fixes: 75722d3992f57 ("[PATCH] ppc64: Thermal control for SMU based machines")
> Cc: stable at vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244 at gmail.com>
> ---
>  drivers/macintosh/windfarm_core.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
> index 5307b1e34261..4003e72f3a57 100644
> --- a/drivers/macintosh/windfarm_core.c
> +++ b/drivers/macintosh/windfarm_core.c
> @@ -436,9 +436,14 @@ EXPORT_SYMBOL_GPL(wf_clear_overtemp);
>
>  static int __init windfarm_core_init(void)
>  {
> +       int err;
> +
>         DBG("wf: core loaded\n");
>
> -       platform_device_register(&wf_platform_device);
> +       err = platform_device_register(&wf_platform_device);
> +       if (err)
> +               platform_device_put(&wf_platform_device);
> +
>         return 0;
>  }
>
> --
> 2.43.0
>

After re-checking it, wf_platform_device 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, so I will drop this patch.

Sorry for the noise.

Best regards,
Guangshuo Li


More information about the Linuxppc-dev mailing list