From: Takashi Iwai <tiwai@suse.de>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Ivan Orlov <ivan.orlov0322@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] ALSA: pcmtest: fix reference leak on failed device registration
Date: Fri, 17 Apr 2026 09:57:20 +0200 [thread overview]
Message-ID: <87h5padnof.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260415193138.3861297-1-lgs201920130244@gmail.com>
On Wed, 15 Apr 2026 21:31:38 +0200,
Guangshuo Li wrote:
>
> When platform_device_register() fails in mod_init(), the embedded struct
> device in pcmtst_pdev has already been initialized by
> device_initialize(), but the failure path returns the error without
> dropping the device reference for the current platform device:
>
> mod_init()
> -> platform_device_register(&pcmtst_pdev)
> -> device_initialize(&pcmtst_pdev.dev)
> -> setup_pdev_dma_masks(&pcmtst_pdev)
> -> platform_device_add(&pcmtst_pdev)
>
> 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.
>
> Fixes: 315a3d57c64c5 ("ALSA: Implement the new Virtual PCM Test Driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Thanks, applied now.
Takashi
next prev parent reply other threads:[~2026-04-17 7:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 19:31 [PATCH] ALSA: pcmtest: fix reference leak on failed device registration Guangshuo Li
2026-04-17 7:57 ` Takashi Iwai [this message]
2026-04-17 10:52 ` Takashi Iwai
2026-04-17 11:30 ` Guangshuo Li
2026-04-23 5:19 ` Jiri Slaby
2026-04-23 7:39 ` Takashi Iwai
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=87h5padnof.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=ivan.orlov0322@gmail.com \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.