From patchwork Thu Jul 26 10:28:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 1241591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 66BB6DFFBF for ; Thu, 26 Jul 2012 11:00:20 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SuLjh-0005yG-Df; Thu, 26 Jul 2012 10:56:05 +0000 Received: from mail-wg0-f41.google.com ([74.125.82.41]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SuLKe-0008H0-AA for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2012 10:30:27 +0000 Received: by wgbds1 with SMTP id ds1so5452485wgb.0 for ; Thu, 26 Jul 2012 03:29:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=vrE+dlSX5E9JWGHKViZLKqRLbPm97cYzt49jreKV0Qc=; b=VxorBlh4qiqc0HSUbXVLCsa5POB2FBwQDXIeEcECKWGZvkPIyjCA/TTWQ7aNz03bG+ a01RxfC6Co29OaxvXSgllOW0qzrgeXDPbUiTrsh0nt5tb6+ix5f3lhjMiyvlTz7cxhiY uykDLW/0XbmpcHuG+72CXytWxx01bu311nfAEnpPAFf2hWG5WmIFlbjpHjQ/df9PcEzK RgrTX5FxtnOYfFYRJ4bGgUBZjBDMcqbs74LwThoqf3JvCoGy+Z9KEksqGorQd/yGC1Wx w7DdmkxusAbZy5Rcj+59xZO1BylJDXaisMZfvB+eDRnTkpUeOHengu98st2WAsBNTA0K 3f7A== Received: by 10.180.100.133 with SMTP id ey5mr12330391wib.4.1343298563452; Thu, 26 Jul 2012 03:29:23 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id fb20sm11559455wid.1.2012.07.26.03.29.21 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 03:29:22 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/21] ASoC: io: Prevent use of regmap if request fails Date: Thu, 26 Jul 2012 11:28:40 +0100 Message-Id: <1343298534-13611-8-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343298534-13611-1-git-send-email-lee.jones@linaro.org> References: <1343298534-13611-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQlCUAceLbPYHgNyixoIup8vMoosxzd62bWOtVRbYqW6DN0yak6Q0RY4MauP4YwtWtR8oxWx X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.41 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: ola.o.lilja@stericsson.com, alsa-devel@alsa-project.org, linus.walleij@stericsson.com, arnd@arndb.de, broonie@opensource.wolfsonmicro.com, olalilja@yahoo.se, STEricsson_nomadik_linux@list.st.com, Lee Jones , lrg@ti.com, sameo@linux.intel.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If a sound codec fails to request a regmap, the 'using_regmap' is set as true regardless, despite there being no regmap to use. As a repercussion, when a latter read function checks to see if we are using regmaps, it assumes we are and attempts to. Only the kernel oopes, because regmap_* tries to extract information from a NULL pointer. Signed-off-by: Lee Jones --- sound/soc/soc-io.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 29183ef..601cb7f 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -52,10 +52,13 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg) if (codec->cache_only) return -1; - ret = regmap_read(codec->control_data, reg, &val); - if (ret == 0) - return val; - else + if (codec->using_regmap) { + ret = regmap_read(codec->control_data, reg, &val); + if (ret == 0) + return val; + else + return -1; + } else return -1; } @@ -141,11 +144,12 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, case SND_SOC_REGMAP: /* Device has made its own regmap arrangements */ - codec->using_regmap = true; if (!codec->control_data) codec->control_data = dev_get_regmap(codec->dev, NULL); if (codec->control_data) { + codec->using_regmap = true; + ret = regmap_get_val_bytes(codec->control_data); /* Errors are legitimate for non-integer byte * multiples */