Skip to contentSkip to conversation

ASoC: Fix snd_soc_register_dais error handling

PATCH Applied Axel Lin 3 participants 3 messages Nov 3, 2010

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 ASoC: Fix snd_soc_register_dais error handling

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().

---
 sound/soc/soc-core.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
sound/soc/soc-core.c +4 -5
index 614a8b3..441285a 100644
@@ -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);
Signature · 1 line
1.7.2
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Axel Lin

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().

---

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
Applied
#2 lore raw
In reply to Axel Lin
Quoted 8 lines · Axel Lin

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().

Applied, thanks.