[PATCH] ALSA: ice1712: Fix missing snd_card_free() at probe error

From: Haotian Zhang

Date: Wed Aug 19 2026 - 08:11:26 EST


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@xxxxxxxxxxx>
---
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