From: Dimitris Papastamos Date: Mon, 10 Jan 2011 10:10:56 +0000 (+0000) Subject: ASoC: soc-core: Add support for NULL default register caches X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=2aa86323d815bab62a7e1d3ef8ed6c81a6dfeffa;p=linux-beck.git ASoC: soc-core: Add support for NULL default register caches 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 Acked-by: Timur Tabi Acked-by: Liam Girdwood Signed-off-by: Mark Brown --- diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 96bf381683f7..4274435853df 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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; + } } }