mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Helge Deller <deller@gmx.de>,
	Guangshuo Li <lgs201920130244@gmail.com>,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] parisc: led: fix reference leak on failed device registration
Date: Thu, 23 Apr 2026 07:24:05 +0200	[thread overview]
Message-ID: <f3cd203e-0acc-4b5c-b590-145c0e82c768@kernel.org> (raw)
In-Reply-To: <929ebeca-d070-4537-b3f5-3a4c93f1301d@gmx.de>

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: stable@vger.kernel.org
>> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
>> ---
>>   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.

See also:
https://patchew.org/linux/20260415174159.3625777-1-lgs201920130244@gmail.com/

thanks,
-- 
js
suse labs


  reply	other threads:[~2026-04-23  5:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15 17:05 Guangshuo Li
2026-04-17  9:39 ` Helge Deller
2026-04-23  5:24   ` Jiri Slaby [this message]
2026-04-23  7:09     ` Helge Deller
2026-04-24  8:25       ` Guangshuo Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3cd203e-0acc-4b5c-b590-145c0e82c768@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=deller@gmx.de \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®