Re: [PATCH] eeprom: digsy_mtc: fix reference leak on failed device registration
From: Guangshuo Li
Date: Fri Apr 24 2026 - 04:21:31 EST
Hi Andy, all,
Thanks for the review.
Please disregard this patch.
On Thu, 16 Apr 2026 at 15:52, Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Thu, Apr 16, 2026 at 12:52:02AM +0800, Guangshuo Li wrote:
> > When platform_device_register() fails in digsy_mtc_eeprom_devices_init(),
> > the embedded struct device in digsy_mtc_eeprom has already been
> > initialized by device_initialize(), but the failure path only removes
> > the software node and does not drop the device reference for the current
> > platform device:
> >
> > digsy_mtc_eeprom_devices_init()
> > -> platform_device_register(&digsy_mtc_eeprom)
> > -> device_initialize(&digsy_mtc_eeprom.dev)
> > -> setup_pdev_dma_masks(&digsy_mtc_eeprom)
> > -> platform_device_add(&digsy_mtc_eeprom)
> >
> > This leads to a reference leak when platform_device_register() fails.
> > Fix this by calling platform_device_put() after removing the software
> > node.
> >
> > The issue was identified by a static analysis tool I developed and
> > confirmed by manual review.
>
> Thanks for catching this up!
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
After re-checking it, digsy_mtc_eeprom 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 confusion, and thanks again for the review.
Best regards,
Guangshuo Li