Skip to content

Commit ab8bce9

Browse files
committed
ALSA: als300: Fix the missing snd_card_free() call at probe error
The previous cleanup with devres may lead to the incorrect release orders at the probe error handling due to the devres's nature. Until we register the card, snd_card_free() has to be called at first for releasing the stuff properly when the driver tries to manage and release the stuff via card->private_free(). This patch fixes it by calling snd_card_free() manually on the error from the probe callback. Fixes: 21a9314 ("ALSA: als300: Allocate resources with device-managed APIs") Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20220412102636.16000-31-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent d04e84b commit ab8bce9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

sound/pci/als300.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ static int snd_als300_probe(struct pci_dev *pci,
708708

709709
err = snd_als300_create(card, pci, chip_type);
710710
if (err < 0)
711-
return err;
711+
goto error;
712712

713713
strcpy(card->driver, "ALS300");
714714
if (chip->chip_type == DEVICE_ALS300_PLUS)
@@ -723,11 +723,15 @@ static int snd_als300_probe(struct pci_dev *pci,
723723

724724
err = snd_card_register(card);
725725
if (err < 0)
726-
return err;
726+
goto error;
727727

728728
pci_set_drvdata(pci, card);
729729
dev++;
730730
return 0;
731+
732+
error:
733+
snd_card_free(card);
734+
return err;
731735
}
732736

733737
static struct pci_driver als300_driver = {

0 commit comments

Comments
 (0)