From patchwork Fri Oct 3 12:32:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 5022121 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0EA029F32B for ; Fri, 3 Oct 2014 12:33:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56AB72017E for ; Fri, 3 Oct 2014 12:33:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2821F2012D for ; Fri, 3 Oct 2014 12:33:16 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 14B5126045D; Fri, 3 Oct 2014 14:33:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id AEA44260467; Fri, 3 Oct 2014 14:33:05 +0200 (CEST) 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 AF6D426046D; Fri, 3 Oct 2014 14:33:04 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id 41859260466 for ; Fri, 3 Oct 2014 14:32:55 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 03 Oct 2014 05:32:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,646,1406617200"; d="scan'208";a="609216172" Received: from mylly.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.158]) by fmsmga002.fm.intel.com with ESMTP; 03 Oct 2014 05:32:45 -0700 From: Jarkko Nikula To: alsa-devel@alsa-project.org Date: Fri, 3 Oct 2014 15:32:40 +0300 Message-Id: <1412339560-18019-1-git-send-email-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.1.1 Cc: Mark Brown , Jarkko Nikula , Liam Girdwood , Lars-Peter Clausen Subject: [alsa-devel] [PATCH] ASoC: dapm: Fix NULL pointer dereference when registering card with widgets 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 X-Virus-Scanned: ClamAV using ClamSMTP Commit 0bd2ac3dae74 ("ASoC: Remove CODEC pointer from snd_soc_dapm_context") introduced regression to snd_soc_dapm_new_controls() when registering a card with card->dapm_widgets set. Call chain is: snd_soc_register_card() -> snd_soc_instantiate_card() -> snd_soc_dapm_new_controls() -> snd_soc_dapm_new_control() Null pointer dereference occurs since card->dapm context doesn't have associated component. Fix this by setting widget codec pointer conditionally. Signed-off-by: Jarkko Nikula Acked-by: Lars-Peter Clausen --- sound/soc/soc-dapm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 2d06892088d5..3f0b4108f7ca 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3125,7 +3125,8 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, } w->dapm = dapm; - w->codec = dapm->component->codec; + if (dapm->component) + w->codec = dapm->component->codec; INIT_LIST_HEAD(&w->sources); INIT_LIST_HEAD(&w->sinks); INIT_LIST_HEAD(&w->list);