From: Haotian Zhang <vulab@iscas.ac.cn>
To: perex@perex.cz, tiwai@suse.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Haotian Zhang <vulab@iscas.ac.cn>
Subject: [PATCH] ALSA: ice1712: Fix missing snd_card_free() at probe error
Date: Wed, 19 Aug 2026 16:49:59 +0800 [thread overview]
Message-ID: <20260819084959.10649-1-vulab@iscas.ac.cn> (raw)
snd_ice1712_probe() performs multiple initialization steps after
snd_card_new(), but directly returns on failures from later steps
without releasing the ALSA card, causing resource leaks when
probing fails.
Route all initialization failures after snd_card_new() to a
common error path and call snd_card_free() before returning
the original error code.
Fixes: ca642da4b33d ("ALSA: ice1712: Allocate resources with device-managed APIs")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
sound/pci/ice1712/ice1712.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 1e39b985bef2..745af0c7020e 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2539,7 +2539,7 @@ static int snd_ice1712_probe(struct pci_dev *pci,
err = snd_ice1712_create(card, pci, model[dev], omni[dev],
cs8427_timeout[dev], dxr_enable[dev]);
if (err < 0)
- return err;
+ goto error;
for (tbl = card_tables; *tbl; tbl++) {
for (c = *tbl; c->subvendor; c++) {
@@ -2550,7 +2550,7 @@ static int snd_ice1712_probe(struct pci_dev *pci,
if (c->chip_init) {
err = c->chip_init(ice);
if (err < 0)
- return err;
+ goto error;
}
ice->card_info = c;
goto __found;
@@ -2562,32 +2562,32 @@ static int snd_ice1712_probe(struct pci_dev *pci,
err = snd_ice1712_pcm_profi(ice, pcm_dev++);
if (err < 0)
- return err;
+ goto error;
if (ice_has_con_ac97(ice)) {
err = snd_ice1712_pcm(ice, pcm_dev++);
if (err < 0)
- return err;
+ goto error;
}
err = snd_ice1712_ac97_mixer(ice);
if (err < 0)
- return err;
+ goto error;
err = snd_ice1712_build_controls(ice);
if (err < 0)
- return err;
+ goto error;
if (c->build_controls) {
err = c->build_controls(ice);
if (err < 0)
- return err;
+ goto error;
}
if (ice_has_con_ac97(ice)) {
err = snd_ice1712_pcm_ds(ice, pcm_dev++);
if (err < 0)
- return err;
+ goto error;
}
if (!c->no_mpu401) {
@@ -2597,7 +2597,7 @@ static int snd_ice1712_probe(struct pci_dev *pci,
MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
-1, &ice->rmidi[0]);
if (err < 0)
- return err;
+ goto error;
if (c->mpu401_1_name)
/* Preferred name available in card_info */
snprintf(ice->rmidi[0]->name,
@@ -2613,7 +2613,7 @@ static int snd_ice1712_probe(struct pci_dev *pci,
-1, &ice->rmidi[1]);
if (err < 0)
- return err;
+ goto error;
if (c->mpu401_2_name)
/* Preferred name available in card_info */
snprintf(ice->rmidi[1]->name,
@@ -2630,10 +2630,13 @@ static int snd_ice1712_probe(struct pci_dev *pci,
err = snd_card_register(card);
if (err < 0)
- return err;
+ goto error;
pci_set_drvdata(pci, card);
dev++;
return 0;
+error:
+ snd_card_free(card);
+ return err;
}
#ifdef CONFIG_PM_SLEEP
--
2.43.0
next reply other threads:[~2026-08-19 12:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 8:49 Haotian Zhang [this message]
2026-08-19 12:53 ` [PATCH] ALSA: ice1712: Fix missing snd_card_free() at probe error Takashi Iwai
2026-08-19 13:47 ` Takashi Iwai
2026-08-20 1:41 ` [PATCH v2] ALSA: ice1712: Fix the card leak at probe error with the auto-cleanup Haotian Zhang
2026-08-20 8:55 ` 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=20260819084959.10649-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox