ASoC: soc-core: Add support for NULL default register caches
authorDimitris Papastamos <dp@opensource.wolfsonmicro.com>
Mon, 10 Jan 2011 10:10:56 +0000 (10:10 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 10 Jan 2011 22:19:31 +0000 (22:19 +0000)
The infrastructure for handling NULL default register maps is already
included in the soc-cache code, just ensure that we don't try to dereference
a NULL pointer while accessing a NULL register cache.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Timur Tabi <timur@freescale.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/soc-core.c

index 96bf381683f7e68566ff60578ddb97600f6778b5..4274435853dff7d36563ecf832a530f3eb7cf681 100644 (file)
@@ -3507,11 +3507,13 @@ int snd_soc_register_codec(struct device *dev,
                 * kernel might have freed the array by the time we initialize
                 * the cache.
                 */
-               codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default,
-                                             reg_size, GFP_KERNEL);
-               if (!codec->reg_def_copy) {
-                       ret = -ENOMEM;
-                       goto fail;
+               if (codec_drv->reg_cache_default) {
+                       codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default,
+                                                     reg_size, GFP_KERNEL);
+                       if (!codec->reg_def_copy) {
+                               ret = -ENOMEM;
+                               goto fail;
+                       }
                }
        }