Re: [PATCH] ALSA: ice1712: Fix missing snd_card_free() at probe error
From: Takashi Iwai
Date: Wed Aug 19 2026 - 08:57:01 EST
On Wed, 19 Aug 2026 10:49:59 +0200,
Haotian Zhang wrote:
>
> 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>
Actually, this was rather a forgotten replacement of snd_card_new()
with snd_devm_card_new(), as implemented in a similar code ice1724.c.
But the error handling before the registration is still needed (it was
fixed later for ice1724.c, too), so it'll be something like below.
thanks,
Takashi
-- 8< --
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2519,8 +2519,8 @@ static int snd_ice1712_create(struct snd_card *card,
static struct snd_ice1712_card_info no_matched;
-static int snd_ice1712_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int __snd_ice1712_probe(struct pci_dev *pci,
+ const struct pci_device_id *pci_id)
{
static int dev;
struct snd_card *card;
@@ -2535,8 +2535,8 @@ static int snd_ice1712_probe(struct pci_dev *pci,
return -ENOENT;
}
- err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
- sizeof(*ice), &card);
+ err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+ sizeof(*ice), &card);
if (err < 0)
return err;
ice = card->private_data;
@@ -2644,6 +2644,12 @@ static int snd_ice1712_probe(struct pci_dev *pci,
return 0;
}
+static int snd_ice1712_probe(struct pci_dev *pci,
+ const struct pci_device_id *pci_id)
+{
+ return snd_card_free_on_error(&pci->dev, __snd_ice1712_probe(pci, pci_id));
+}
+
#ifdef CONFIG_PM_SLEEP
static int snd_ice1712_suspend(struct device *dev)
{