public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Fix snd_soc_register_dais error handling
@ 2010-11-03  7:04 Axel Lin
  2010-11-03  9:07 ` Liam Girdwood
  2010-11-03 13:12 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2010-11-03  7:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, Takashi Iwai

kzalloc for dai may fail at any iteration of the for loop,
thus properly unregister already registered DAIs before return error.

The error handling code in snd_soc_register_dais() already ensure all the DAIs
are unregistered before return error, we can remove the error handling code
to unregister DAIs in snd_soc_register_codec().

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 sound/soc/soc-core.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 614a8b3..441285a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3043,8 +3043,10 @@ int snd_soc_register_dais(struct device *dev,
 	for (i = 0; i < count; i++) {
 
 		dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL);
-		if (dai == NULL)
-			return -ENOMEM;
+		if (dai == NULL) {
+			ret = -ENOMEM;
+			goto err;
+		}
 
 		/* create DAI component name */
 		dai->name = fmt_multiple_name(dev, &dai_drv[i]);
@@ -3263,9 +3265,6 @@ int snd_soc_register_codec(struct device *dev,
 	return 0;
 
 error:
-	for (i--; i >= 0; i--)
-		snd_soc_unregister_dai(dev);
-
 	if (codec->reg_cache)
 		kfree(codec->reg_cache);
 	kfree(codec->name);
-- 
1.7.2




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

* Re: [PATCH] ASoC: Fix snd_soc_register_dais error handling
  2010-11-03  7:04 [PATCH] ASoC: Fix snd_soc_register_dais error handling Axel Lin
@ 2010-11-03  9:07 ` Liam Girdwood
  2010-11-03 13:12 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2010-11-03  9:07 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Mark Brown, Takashi Iwai

On Wed, 2010-11-03 at 15:04 +0800, Axel Lin wrote:
> kzalloc for dai may fail at any iteration of the for loop,
> thus properly unregister already registered DAIs before return error.
> 
> The error handling code in snd_soc_register_dais() already ensure all the DAIs
> are unregistered before return error, we can remove the error handling code
> to unregister DAIs in snd_soc_register_codec().
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk


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

* Re: [PATCH] ASoC: Fix snd_soc_register_dais error handling
  2010-11-03  7:04 [PATCH] ASoC: Fix snd_soc_register_dais error handling Axel Lin
  2010-11-03  9:07 ` Liam Girdwood
@ 2010-11-03 13:12 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2010-11-03 13:12 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Takashi Iwai

On Wed, Nov 03, 2010 at 03:04:45PM +0800, Axel Lin wrote:
> kzalloc for dai may fail at any iteration of the for loop,
> thus properly unregister already registered DAIs before return error.
> 
> The error handling code in snd_soc_register_dais() already ensure all the DAIs
> are unregistered before return error, we can remove the error handling code
> to unregister DAIs in snd_soc_register_codec().
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2010-11-03 13:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-03  7:04 [PATCH] ASoC: Fix snd_soc_register_dais error handling Axel Lin
2010-11-03  9:07 ` Liam Girdwood
2010-11-03 13:12 ` Mark Brown

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