Skip to content

Commit 6ebc16e

Browse files
committed
ALSA: oxygen: 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() on the error from the probe callback using a new helper function. Fixes: 596ae97 ("ALSA: oxygen: Allocate resources with device-managed APIs") Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20220412102636.16000-35-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 60797a2 commit 6ebc16e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

sound/pci/oxygen/oxygen_lib.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ static void oxygen_card_free(struct snd_card *card)
576576
mutex_destroy(&chip->mutex);
577577
}
578578

579-
int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
579+
static int __oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
580580
struct module *owner,
581581
const struct pci_device_id *ids,
582582
int (*get_model)(struct oxygen *chip,
@@ -701,6 +701,16 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
701701
pci_set_drvdata(pci, card);
702702
return 0;
703703
}
704+
705+
int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
706+
struct module *owner,
707+
const struct pci_device_id *ids,
708+
int (*get_model)(struct oxygen *chip,
709+
const struct pci_device_id *id))
710+
{
711+
return snd_card_free_on_error(&pci->dev,
712+
__oxygen_pci_probe(pci, index, id, owner, ids, get_model));
713+
}
704714
EXPORT_SYMBOL(oxygen_pci_probe);
705715

706716
#ifdef CONFIG_PM_SLEEP

0 commit comments

Comments
 (0)