Re: [PATCH] ASoC: Fix resource leak if soc_register_ac97_dai_link failed

From: Mike Frysinger
Date: Tue Jan 11 2011 - 19:19:40 EST


On Tue, Dec 7, 2010 at 07:56, Axel Lin wrote:
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1619,12 +1619,14 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
> Â#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_dai_err;
> Â Â Â Â Â Â Â Â}
> + Â Â Â }
> Â#endif

this isnt entirely correct. soc_unregister_ac97_dai_link takes a
pointer to a codec which card->rtd[i] is not.
sound/soc/soc-core.c: In function âsnd_soc_instantiate_cardâ:
sound/soc/soc-core.c:1626: warning: passing argument 1 of
âsoc_unregister_ac97_dai_linkâ from incompatible pointer type
-mike
èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—