From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] ALSA: pcmtest: Fix leak at probe error
Date: Tue, 6 Oct 2026 19:39:54 +0200 [thread overview]
Message-ID: <20261006174002.703431-3-tiwai@suse.de> (raw)
In-Reply-To: <20261006174002.703431-1-tiwai@suse.de>
When an error happens at probe of pcmtest driver before
snd_card_register() succeeds, we have to release the card explicitly,
but it's not done, leading to a potential memory leak.
Use the new auto-clean mechanism to handle the error case at probe.
Fixes: 315a3d57c64c ("ALSA: Implement the new Virtual PCM Test Driver")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/drivers/pcmtest.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c
index fea9580593e6..4733f7c7729f 100644
--- a/sound/drivers/pcmtest.c
+++ b/sound/drivers/pcmtest.c
@@ -596,7 +596,7 @@ static int snd_pcmtst_create(struct snd_card *card, struct platform_device *pdev
static int pcmtst_probe(struct platform_device *pdev)
{
- struct snd_card *card;
+ struct snd_card *card __free(snd_card_free) = NULL;
struct pcmtst *pcmtst;
int err;
@@ -620,6 +620,7 @@ static int pcmtst_probe(struct platform_device *pdev)
return err;
platform_set_drvdata(pdev, pcmtst);
+ card = NULL; /* probe succeeded, don't release as error */
return 0;
}
--
2.55.0
next prev parent reply other threads:[~2026-10-06 17:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 17:39 [PATCH 0/5] ALSA: Fix yet more bugs reported by Sashiko Takashi Iwai
2026-10-06 17:39 ` [PATCH 1/5] ALSA: seq: Fix missing direction and ump_group handling in 32bit compat ioctl Takashi Iwai
2026-10-06 17:39 ` Takashi Iwai [this message]
2026-10-06 17:39 ` [PATCH 3/5] ALSA: aloop: Avoid a bad mixure of guard() and goto Takashi Iwai
2026-10-06 17:39 ` [PATCH 4/5] ALSA: core: Fix leaks at snd_card_init() error paths Takashi Iwai
2026-10-06 17:39 ` [PATCH 5/5] ALSA: seq: Don't lose partial read failure 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=20261006174002.703431-3-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@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®