public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Fix resource leak if soc_register_ac97_dai_link failed
@ 2010-12-07 12:56 Axel Lin
  2010-12-07 15:26 ` Mark Brown
  2011-01-12  0:19 ` Mike Frysinger
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2010-12-07 12:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, alsa-devel

Properly free the resources in the case of soc_register_ac97_dai_link failure.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---

This patch is against Linus tree.

Regards,
Axel
 sound/soc/soc-core.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 441285a..d7f80c3 100644
--- 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
 
 	card->instantiated = 1;
-- 
1.7.0.4




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: Fix resource leak if soc_register_ac97_dai_link failed
  2010-12-07 12:56 [PATCH] ASoC: Fix resource leak if soc_register_ac97_dai_link failed Axel Lin
@ 2010-12-07 15:26 ` Mark Brown
  2011-01-12  0:19 ` Mike Frysinger
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2010-12-07 15:26 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, alsa-devel

On Tue, Dec 07, 2010 at 08:56:30PM +0800, Axel Lin wrote:
> Properly free the resources in the case of soc_register_ac97_dai_link failure.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: Fix resource leak if soc_register_ac97_dai_link failed
  2010-12-07 12:56 [PATCH] ASoC: Fix resource leak if soc_register_ac97_dai_link failed Axel Lin
  2010-12-07 15:26 ` Mark Brown
@ 2011-01-12  0:19 ` Mike Frysinger
  2011-01-12  1:42   ` Axel Lin
  1 sibling, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2011-01-12  0:19 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Mark Brown, alsa-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 1631 bytes --]

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Ç+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: Fix resource leak if soc_register_ac97_dai_link failed
  2011-01-12  0:19 ` Mike Frysinger
@ 2011-01-12  1:42   ` Axel Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2011-01-12  1:42 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-kernel, Liam Girdwood, Mark Brown, alsa-devel

> 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
>

Ooops. my bad.
I will send a patch for 2.6.37 to fix it.
Thanks for report this bug.

Regards,
Axel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-12  1:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-07 12:56 [PATCH] ASoC: Fix resource leak if soc_register_ac97_dai_link failed Axel Lin
2010-12-07 15:26 ` Mark Brown
2011-01-12  0:19 ` Mike Frysinger
2011-01-12  1:42   ` Axel Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox