Re: [PATCH] platform/x86: intel_scu_wdt: fix reference leak on failed device registration
From: Andy Shevchenko
Date: Thu Apr 16 2026 - 04:03:48 EST
On Thu, Apr 16, 2026 at 02:00:42AM +0800, Guangshuo Li wrote:
> When platform_device_register() fails in register_mid_wdt(), the
> embedded struct device in wdt_dev has already been initialized by
> device_initialize(), but the failure path returns the error without
> dropping the device reference for the current platform device:
>
> register_mid_wdt()
> -> platform_device_register(&wdt_dev)
> -> device_initialize(&wdt_dev.dev)
> -> setup_pdev_dma_masks(&wdt_dev)
> -> platform_device_add(&wdt_dev)
>
> 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.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
--
With Best Regards,
Andy Shevchenko