Skip to content

Commit

Permalink
ALSA: sis7019: Fix the missing error handling
Browse files Browse the repository at this point in the history
The previous cleanup with devres forgot to replace the snd_card_free()
call with the devm version.  Moreover, it still needs the manual call
of snd_card_free() at the probe error path, otherwise the reverse
order of the releases may happen.  This patch addresses those issues.

Fixes: 499ddc1 ("ALSA: sis7019: Allocate resources with device-managed APIs")
Cc: <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Apr 12, 2022
1 parent 5e154df commit 2236a32
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sound/pci/sis7019.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,8 +1331,8 @@ static int sis_chip_create(struct snd_card *card,
return 0;
}

static int snd_sis7019_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
static int __snd_sis7019_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{
struct snd_card *card;
struct sis7019 *sis;
Expand All @@ -1352,8 +1352,8 @@ static int snd_sis7019_probe(struct pci_dev *pci,
if (!codecs)
codecs = SIS_PRIMARY_CODEC_PRESENT;

rc = snd_card_new(&pci->dev, index, id, THIS_MODULE,
sizeof(*sis), &card);
rc = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE,
sizeof(*sis), &card);
if (rc < 0)
return rc;

Expand Down Expand Up @@ -1386,6 +1386,12 @@ static int snd_sis7019_probe(struct pci_dev *pci,
return 0;
}

static int snd_sis7019_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{
return snd_card_free_on_error(&pci->dev, __snd_sis7019_probe(pci, pci_id));
}

static struct pci_driver sis7019_driver = {
.name = KBUILD_MODNAME,
.id_table = snd_sis7019_ids,
Expand Down

0 comments on commit 2236a32

Please sign in to comment.