Re: [PATCH] parisc: led: fix reference leak on failed device registration

Helge Deller <[email protected]>
Newsgroups org.kernel.vger.linux-parisc,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hi Jiri,

On 4/23/26 07:24, Jiri Slaby wrote:
> On 17. 04. 26, 11:39, Helge Deller wrote:
>> On 4/15/26 19:05, Guangshuo Li wrote:
>>> When platform_device_register() fails in startup_leds(), the embedded
>>> struct device in platform_leds has already been initialized by
>>> device_initialize(), but the failure path only reports the error and
>>> does not drop the device reference for the current platform device:
>>>
>>>    startup_leds()
>>>      -> platform_device_register(&platform_leds)
>>>         -> device_initialize(&platform_leds.dev)
>>>         -> setup_pdev_dma_masks(&platform_leds)
>>>         -> platform_device_add(&platform_leds)
>>>
>>> This leads to a reference leak when platform_device_register() fails.
>>> Fix this by calling platform_device_put() after reporting the error.
>>>
>>> The issue was identified by a static analysis tool I developed and
>>> confirmed by manual review.
>>>
>>> Fixes: 789e527adfc33 ("parisc: led: Rewrite LED/LCD driver to utilizize Linux LED subsystem")
>>> Cc: [email protected]
>>> Signed-off-by: Guangshuo Li <[email protected]>
>>> ---
>>>   drivers/parisc/led.c | 6 ++++--
>>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> applied.
>> Thanks!
>> Helge
> 
> Unless the static pcmtst_pdev has ->type->release or ->release set, the patch triggers a warning upon put().
> 
> platform_device_register() should be fixed instead.

Thanks for the notice! I'm going to revert that patch.

Just yesterday I refused to apply the other patches for fbdev and suggested
to fix platform_device_register() instead. See:
https://marc.info/?l=linux-fbdev&m=177687117206684&w=2

> See also:
> https://patchew.org/linux/[email protected]/
Thanks!
Helge
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.