]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
ASoC: Fix snd_soc_register_dais error handling
authorAxel Lin <axel.lin@gmail.com>
Wed, 3 Nov 2010 07:04:45 +0000 (15:04 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 3 Nov 2010 13:08:20 +0000 (09:08 -0400)
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>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/soc-core.c

index 614a8b30d87bdefdb99414f06d1d74438e60cd18..441285ade024ff33589cd22204ef5cb82a1f14ea 100644 (file)
@@ -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);