[PATCH 04/32] ALSA: ali5451: Use auto-cleanup for probe card error handling

From: Takashi Iwai

Date: Thu Oct 01 2026 - 07:09:34 EST


Instead of the manual call of snd_card_free_on_error(), use the
auto-cleanup feature.

Merely a code cleanup, and no functional changes.

Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
sound/pci/ali5451/ali5451.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index f07c5f4c2380..9d1d57c718d0 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -2086,10 +2086,10 @@ static int snd_ali_create(struct snd_card *card,
return 0;
}

-static int __snd_ali_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int snd_ali_probe(struct pci_dev *pci,
+ const struct pci_device_id *pci_id)
{
- struct snd_card *card;
+ struct snd_card *card __free(snd_card_unref) = NULL;
struct snd_ali *codec;
int err;

@@ -2129,15 +2129,10 @@ static int __snd_ali_probe(struct pci_dev *pci,
return err;

pci_set_drvdata(pci, card);
+ card = NULL; /* probe succeeded, don't release as error */
return 0;
}

-static int snd_ali_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
-{
- return snd_card_free_on_error(&pci->dev, __snd_ali_probe(pci, pci_id));
-}
-
static struct pci_driver ali5451_driver = {
.name = KBUILD_MODNAME,
.id_table = snd_ali_ids,
--
2.55.0