Skip to content

Commit c5e58c4

Browse files
committed
ALSA: cs46xx: Fix 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: 5bff69b ("ALSA: cs46xx: Allocate resources with device-managed APIs") Cc: <[email protected]> Reported-and-tested-by: Jan Engelhardt <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent dd84cff commit c5e58c4

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

sound/pci/cs46xx/cs46xx.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,36 +74,36 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci,
7474
err = snd_cs46xx_create(card, pci,
7575
external_amp[dev], thinkpad[dev]);
7676
if (err < 0)
77-
return err;
77+
goto error;
7878
card->private_data = chip;
7979
chip->accept_valid = mmap_valid[dev];
8080
err = snd_cs46xx_pcm(chip, 0);
8181
if (err < 0)
82-
return err;
82+
goto error;
8383
#ifdef CONFIG_SND_CS46XX_NEW_DSP
8484
err = snd_cs46xx_pcm_rear(chip, 1);
8585
if (err < 0)
86-
return err;
86+
goto error;
8787
err = snd_cs46xx_pcm_iec958(chip, 2);
8888
if (err < 0)
89-
return err;
89+
goto error;
9090
#endif
9191
err = snd_cs46xx_mixer(chip, 2);
9292
if (err < 0)
93-
return err;
93+
goto error;
9494
#ifdef CONFIG_SND_CS46XX_NEW_DSP
9595
if (chip->nr_ac97_codecs ==2) {
9696
err = snd_cs46xx_pcm_center_lfe(chip, 3);
9797
if (err < 0)
98-
return err;
98+
goto error;
9999
}
100100
#endif
101101
err = snd_cs46xx_midi(chip, 0);
102102
if (err < 0)
103-
return err;
103+
goto error;
104104
err = snd_cs46xx_start_dsp(chip);
105105
if (err < 0)
106-
return err;
106+
goto error;
107107

108108
snd_cs46xx_gameport(chip);
109109

@@ -117,11 +117,15 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci,
117117

118118
err = snd_card_register(card);
119119
if (err < 0)
120-
return err;
120+
goto error;
121121

122122
pci_set_drvdata(pci, card);
123123
dev++;
124124
return 0;
125+
126+
error:
127+
snd_card_free(card);
128+
return err;
125129
}
126130

127131
static struct pci_driver cs46xx_driver = {

0 commit comments

Comments
 (0)