Skip to content

Commit

Permalink
ASoC: Fix snd_soc_instantiate_card error path
Browse files Browse the repository at this point in the history
Properly free the resources in the case of snd_card_register failure
and soc_register_ac97_dai_link failure.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Dec 7, 2010
1 parent 0b9a214 commit 6b3ed78
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1839,18 +1839,20 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
ret = snd_card_register(card->snd_card);
if (ret < 0) {
printk(KERN_ERR "asoc: failed to register soundcard for %s\n", card->name);
goto probe_dai_err;
goto probe_aux_dev_err;
}

#ifdef CONFIG_SND_SOC_AC97_BUS
/* register any AC97 codecs */
for (i = 0; i < card->num_rtd; i++) {
ret = soc_register_ac97_dai_link(&card->rtd[i]);
if (ret < 0) {
printk(KERN_ERR "asoc: failed to register AC97 %s\n", card->name);
goto probe_dai_err;
}
ret = soc_register_ac97_dai_link(&card->rtd[i]);
if (ret < 0) {
printk(KERN_ERR "asoc: failed to register AC97 %s\n", card->name);
while (--i >= 0)
soc_unregister_ac97_dai_link(&card->rtd[i]);
goto probe_aux_dev_err;
}
}
#endif

card->instantiated = 1;
Expand Down

0 comments on commit 6b3ed78

Please sign in to comment.