From patchwork Fri Nov 2 11:23:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 150026 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1950796ljp; Fri, 2 Nov 2018 04:24:03 -0700 (PDT) X-Google-Smtp-Source: AJdET5cVBPBqojqTgDImSdE6bSewlFauu9okCMoWoTy7XZhaQXRnkFBkkD96RIajfdgI6JToP7T4 X-Received: by 2002:a5d:6309:: with SMTP id i9-v6mr9500438wru.163.1541157842723; Fri, 02 Nov 2018 04:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541157842; cv=none; d=google.com; s=arc-20160816; b=MJSgGPLfFjh+Ff/ullT8swY0hyztDVlSyenR1ZHSzM6L2Ta/Ssy+7xmXuVv4uX+2QC EfO6TdQ431cuUTOpJpZODzPTlsk36GsQURouyPoVQy3bpAOValKnO+LoE/551wUeSOgm hHXke86m10/766i2mL0gRyIwpRjujxXuGmvVzZE5nD7xsTyL8tAEV0ftY0VcWtyr6QLy NF3fhKkYU10lf3B2PwuAPnwzLB/qj9sCxYqmC97tri2VpYDtKga6/bBo8NdrVN81/khV V4Docy6qt2luMMQ/Ss8l2WGouJXrowe+P7Zzaq+0g4yF/tvWZq34zNslVDwPNEvwGlLC zuPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from:delivered-to; bh=VppNHdopg10uYRUjUNBG7W+4RjPPzbvH9eQBkUI8Jgk=; b=KEpmaB6fwo+biZue6nYWesVZOOzv51owQ17QByOqZej8MD9XnrAro9kKy33nSPosUM FmEhVt3yqSjRIGOPL93l2KhzAm0H31JM3fuql6NO3Vl6t6YBk1Kwkc3TbAi0+u4+TRAM /y/zEHMXfAvxKlk9EYJaopdX7499YcatXSjrZOWyLxVMp7b7YHlGoppAestwZZcomMsp asD2mjCBdEIpwjBlYlX/jJjbKUKJilCdzqXUFp55E0ndtaOWRjEsC+pY4nK3ff75IK2j bXqSHuiIqZg2Hjw4wv79+g9Ai90Db9Yu170NseuLkCG//u9pcUo6UK2Ju6nb81zSHX7u y+qQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id e10-v6si28984111wrn.344.2018.11.02.04.24.02; Fri, 02 Nov 2018 04:24:02 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 22F3826792C; Fri, 2 Nov 2018 12:24:01 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C2826267950; Fri, 2 Nov 2018 12:23:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE autolearn=disabled version=3.4.0 Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) by alsa0.perex.cz (Postfix) with ESMTP id 8F0882675BA for ; Fri, 2 Nov 2018 12:23:56 +0100 (CET) Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MRn0U-1g88Da225y-00TD6I; Fri, 02 Nov 2018 12:23:44 +0100 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MRn0U-1g88Da225y-00TD6I; Fri, 02 Nov 2018 12:23:44 +0100 From: Arnd Bergmann To: Jaroslav Kysela , Takashi Iwai Date: Fri, 2 Nov 2018 12:23:08 +0100 Message-Id: <20181102112341.753642-1-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 X-Provags-ID: V03:K1:p4SjToA2wDkzy87nT7PmccmbzdjVj3zQ/2VfwD77kpJAm1BRctz cm5RN/7k7UNSDNFKP6i2vLBHYnUlLcYAA4em40dM5ATl+PdnsyXqEOsQKWzNrsj3tuvNRFQ gd4l6A1iUzX8nQzWVCaX7SAQyamhKxZBuqk6EpwpNZAijBiRry/zohoQV5W+0LOgZPgRrlN D/fixGNCOmlZYAHqys8iA== X-UI-Out-Filterresults: notjunk:1; V01:K0:phAlVAziqS8=:jVa0FSb3sXpoMYBkRpQXNd vNYqr+xRzzO/dKdskfeH0EYWBgrGsVzXjo4DM4J0026FlzwzcG3EbqSXUOfA3wsbkxshbP37l aaD3r2WJP+nhRa4oJDQCFncEVYvAb6kzhzD8cSnx+tcBvp/vIfb5wTbFUil1A5BRls/99wxeD UFkT/JDTPSa9/d9qSNVOeYQspCsSal8h/IWdaRA69+Ei7fQ+eTKcNhZ0JRde1QqWSCcsuAFxg 7evZE6cmK22E0R434nIZkm1zcUbCOGoWQ5Lv+mUXUNNWE7SOV4QoR54WLZFaWQ9qA99kPbnas DwgFyJXdqz+N+i+6IYzBwnGHIgVcn7L0Luo3vLcBaQC9HBcHdG4hEjGftnVZKoT9eYuPOtm7m yeNmDH4XlTO9Cxqtcg/pFTKauXb3csfW5BePetqjLeEeR+Xywg8S4QGD8B4Bmg+ZtHxJ58dwW 5J3EUDE9ohRsJtSl8qGd6VdFRwndFGOHtrOgPqgpVClJx2wgP7OqiV9wkJMhtFrz+rBKM5Wkw ZnZ9nVm+XShis/6JXi43iOtiaRKixSsG2N6dnWlf1bEvWdrCYLalLvcPJPCeayJ28dWUIEF/a 3+MT1x+0Hpirp88w4RlR6qWeYDmu6zZoxZf/TT/4ewNFR7ptwc84DIP0ymsdwm/coJ+L+GpRv K5vEzMlmY/OrThmH/TpXZIVOQuTbmWn7EzMGhzbZEqWLbydKu6NA1QP4RMP9jInqRUNE= Cc: alsa-devel@alsa-project.org, Charles Keepax , Arnd Bergmann , Kuninori Morimoto , patches@opensource.cirrus.com, Liam Girdwood , linux-kernel@vger.kernel.org, Mark Brown , Fabio Estevam , Robert Jarzmik Subject: [alsa-devel] [PATCH] ASoC: wm97xx: fix uninitialized regmap pointer problem X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org gcc notices that without either the ac97 bus or the pdata, we never initialize the regmap pointer, which leads to an uninitialized variable access: sound/soc/codecs/wm9712.c: In function 'wm9712_soc_probe': sound/soc/codecs/wm9712.c:666:2: error: 'regmap' may be used uninitialized in this function [-Werror=maybe-uninitialized] Since that configuration is invalid, it's better to return an error here. I tried to avoid adding complexity to the conditions, and turned the #ifdef into a regular if(IS_ENABLED()) check for readability. This in turn requires moving some header file declarations out of an #ifdef. The same code is used in three drivers, all of which I'm changing the same way. Fixes: 2ed1a8e0ce8d ("ASoC: wm9712: add ac97 new bus support") Signed-off-by: Arnd Bergmann --- include/sound/soc.h | 2 +- sound/soc/codecs/wm9705.c | 10 ++++------ sound/soc/codecs/wm9712.c | 10 ++++------ sound/soc/codecs/wm9713.c | 10 ++++------ 4 files changed, 13 insertions(+), 19 deletions(-) -- 2.18.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/include/sound/soc.h b/include/sound/soc.h index 70c10a8f3e90..3e0ac310a3df 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -553,12 +553,12 @@ static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, } #endif -#ifdef CONFIG_SND_SOC_AC97_BUS struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component); struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component, unsigned int id, unsigned int id_mask); void snd_soc_free_ac97_component(struct snd_ac97 *ac97); +#ifdef CONFIG_SND_SOC_AC97_BUS int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops); int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops, struct platform_device *pdev); diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index ccdf088461b7..54c306707c02 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c @@ -325,8 +325,7 @@ static int wm9705_soc_probe(struct snd_soc_component *component) if (wm9705->mfd_pdata) { wm9705->ac97 = wm9705->mfd_pdata->ac97; regmap = wm9705->mfd_pdata->regmap; - } else { -#ifdef CONFIG_SND_SOC_AC97_BUS + } else if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS)) { wm9705->ac97 = snd_soc_new_ac97_component(component, WM9705_VENDOR_ID, WM9705_VENDOR_ID_MASK); if (IS_ERR(wm9705->ac97)) { @@ -339,7 +338,8 @@ static int wm9705_soc_probe(struct snd_soc_component *component) snd_soc_free_ac97_component(wm9705->ac97); return PTR_ERR(regmap); } -#endif + } else { + return -ENXIO; } snd_soc_component_set_drvdata(component, wm9705->ac97); @@ -350,14 +350,12 @@ static int wm9705_soc_probe(struct snd_soc_component *component) static void wm9705_soc_remove(struct snd_soc_component *component) { -#ifdef CONFIG_SND_SOC_AC97_BUS struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component); - if (!wm9705->mfd_pdata) { + if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS) && !wm9705->mfd_pdata) { snd_soc_component_exit_regmap(component); snd_soc_free_ac97_component(wm9705->ac97); } -#endif } static const struct snd_soc_component_driver soc_component_dev_wm9705 = { diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index e873baa9e778..01949eaba4fd 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -642,8 +642,7 @@ static int wm9712_soc_probe(struct snd_soc_component *component) if (wm9712->mfd_pdata) { wm9712->ac97 = wm9712->mfd_pdata->ac97; regmap = wm9712->mfd_pdata->regmap; - } else { -#ifdef CONFIG_SND_SOC_AC97_BUS + } else if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS)) { int ret; wm9712->ac97 = snd_soc_new_ac97_component(component, WM9712_VENDOR_ID, @@ -660,7 +659,8 @@ static int wm9712_soc_probe(struct snd_soc_component *component) snd_soc_free_ac97_component(wm9712->ac97); return PTR_ERR(regmap); } -#endif + } else { + return -ENXIO; } snd_soc_component_init_regmap(component, regmap); @@ -673,14 +673,12 @@ static int wm9712_soc_probe(struct snd_soc_component *component) static void wm9712_soc_remove(struct snd_soc_component *component) { -#ifdef CONFIG_SND_SOC_AC97_BUS struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); - if (!wm9712->mfd_pdata) { + if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS) && !wm9712->mfd_pdata) { snd_soc_component_exit_regmap(component); snd_soc_free_ac97_component(wm9712->ac97); } -#endif } static const struct snd_soc_component_driver soc_component_dev_wm9712 = { diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 643863bb32e0..b2bb465c8e5a 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -1214,8 +1214,7 @@ static int wm9713_soc_probe(struct snd_soc_component *component) if (wm9713->mfd_pdata) { wm9713->ac97 = wm9713->mfd_pdata->ac97; regmap = wm9713->mfd_pdata->regmap; - } else { -#ifdef CONFIG_SND_SOC_AC97_BUS + } else if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS)) { wm9713->ac97 = snd_soc_new_ac97_component(component, WM9713_VENDOR_ID, WM9713_VENDOR_ID_MASK); if (IS_ERR(wm9713->ac97)) @@ -1225,7 +1224,8 @@ static int wm9713_soc_probe(struct snd_soc_component *component) snd_soc_free_ac97_component(wm9713->ac97); return PTR_ERR(regmap); } -#endif + } else { + return -ENXIO; } snd_soc_component_init_regmap(component, regmap); @@ -1238,14 +1238,12 @@ static int wm9713_soc_probe(struct snd_soc_component *component) static void wm9713_soc_remove(struct snd_soc_component *component) { -#ifdef CONFIG_SND_SOC_AC97_BUS struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); - if (!wm9713->mfd_pdata) { + if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS)) { snd_soc_component_exit_regmap(component); snd_soc_free_ac97_component(wm9713->ac97); } -#endif } static const struct snd_soc_component_driver soc_component_dev_wm9713 = {