From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dimitris Papastamos Subject: [PATCH] ASoC: soc-core: Add support for NULL default register caches Date: Mon, 10 Jan 2011 10:10:56 +0000 Message-ID: <1294654256-1012-1-git-send-email-dp@opensource.wolfsonmicro.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from opensource2.wolfsonmicro.com (opensource.wolfsonmicro.com [80.75.67.52]) by alsa0.perex.cz (Postfix) with ESMTP id EAD10243D4 for ; Mon, 10 Jan 2011 11:10:59 +0100 (CET) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Mark Brown , Liam Girdwood Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, Timur Tabi List-Id: alsa-devel@alsa-project.org 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 --- sound/soc/soc-core.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index bac7291..a9f19c1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3503,11 +3503,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; + } } } -- 1.7.3.5