From: Takashi Iwai <tiwai@suse.de>
To: Haotian Zhang <vulab@iscas.ac.cn>
Cc: perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: ice1712: Fix missing snd_card_free() at probe error
Date: Wed, 19 Aug 2026 14:53:17 +0200 [thread overview]
Message-ID: <87ik56nuf6.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260819084959.10649-1-vulab@iscas.ac.cn>
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@iscas.ac.cn>
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)
{
next prev parent reply other threads:[~2026-08-19 12:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 8:49 [PATCH] ALSA: ice1712: Fix missing snd_card_free() at probe error Haotian Zhang
2026-08-19 12:53 ` Takashi Iwai [this message]
2026-08-19 13:47 ` 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=87ik56nuf6.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=vulab@iscas.ac.cn \
/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;
as well as URLs for NNTP newsgroup(s).