[alsa-devel] [PATCH] ASoC: snd-core: tidyup snd_soc_register_codec() fail case

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Mon Feb 25 09:40:09 CET 2013


kfree() on snd_soc_register_codec() was summarized to one place.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
 sound/soc/soc-core.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 689eb04..ceac893 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3983,8 +3983,8 @@ int snd_soc_register_codec(struct device *dev,
 	/* create CODEC component name */
 	codec->name = fmt_single_name(dev, &codec->id);
 	if (codec->name == NULL) {
-		kfree(codec);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto fail_codec;
 	}
 
 	if (codec_drv->compress_type)
@@ -4023,7 +4023,7 @@ int snd_soc_register_codec(struct device *dev,
 						      reg_size, GFP_KERNEL);
 			if (!codec->reg_def_copy) {
 				ret = -ENOMEM;
-				goto fail;
+				goto fail_codec_name;
 			}
 		}
 	}
@@ -4057,8 +4057,9 @@ int snd_soc_register_codec(struct device *dev,
 	dev_dbg(codec->dev, "ASoC: Registered codec '%s'\n", codec->name);
 	return 0;
 
-fail:
+fail_codec_name:
 	kfree(codec->name);
+fail_codec:
 	kfree(codec);
 	return ret;
 }
-- 
1.7.9.5



More information about the Alsa-devel mailing list