From patchwork Fri Jul 4 08:53:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 4478951 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 0AF429F36A for ; Fri, 4 Jul 2014 08:57:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42CAD2041B for ; Fri, 4 Jul 2014 08:57:23 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id EB1A820416 for ; Fri, 4 Jul 2014 08:57:21 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id CB5832659D5; Fri, 4 Jul 2014 10:57:19 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 799672659AF; Fri, 4 Jul 2014 10:56:52 +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 7CA51265994; Fri, 4 Jul 2014 10:56:51 +0200 (CEST) Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by alsa0.perex.cz (Postfix) with ESMTP id C4F4C265994 for ; Fri, 4 Jul 2014 10:56:42 +0200 (CEST) Received: by mail-pd0-f170.google.com with SMTP id z10so1681913pdj.1 for ; Fri, 04 Jul 2014 01:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Fpd2VHHJFrkaz9hsDW4oUNAjjisgrFy4MYDlo05OUQY=; b=Nh2JV+fgy0w0lAiQM/byzSedJilDp0718fckJKsRdmIa82E+xLBqaQg2SBsU0oWppC Po07Op0B/ii9I9rxlllv5sCK0EJp9tl4bhl+4qEIj+XDbL6kzx5s9Jowkb3HRRUqbTQg KOwy5e7yqhCO5ty7qsiRB6wXFpDAyJlYTFQNTngv6BTSeIADVd0TyU5qs7SoWHOdbrFA C/wtMohy63cSF++mDl6wrfIVHbLVkdGxgcxwhiF7+W6BMmhalpYXSk+2AzQhJV92gk9h gzFuyXmSaTaSdeuoo/O5w0Z1gn67QnRIatioUEUnOtWs7VLdB1Ob1zCGoZoR0qkMq0sy vpbw== X-Received: by 10.66.131.39 with SMTP id oj7mr9845978pab.20.1404464201297; Fri, 04 Jul 2014 01:56:41 -0700 (PDT) Received: from linaro.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id nz7sm8005901pdb.48.2014.07.04.01.56.36 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Jul 2014 01:56:40 -0700 (PDT) From: Tushar Behera To: alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org Date: Fri, 4 Jul 2014 14:23:00 +0530 Message-Id: <1404463980-25027-2-git-send-email-tushar.b@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404463980-25027-1-git-send-email-tushar.b@samsung.com> References: <1404463980-25027-1-git-send-email-tushar.b@samsung.com> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, dianders@chromium.org, pawel.moll@arm.com, lgirdwood@gmail.com, tiwai@suse.de, ijc+devicetree@hellion.org.uk, linux-kernel@vger.kernel.org, robh+dt@kernel.org, trblinux@gmail.com, broonie@kernel.org, galak@codeaurora.org, kgene.kim@samsung.com Subject: [alsa-devel] [PATCH 2/2] ASoC: core: Fix possible NULL pointer dereference 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 snd_soc_of_parse_card_name() may be called before card->dev has been set, which results in a kernel panic. Unable to handle kernel NULL pointer dereference at virtual address 00000210 PC is at snd_soc_of_parse_card_name+0x18/0x54 LR is at snow_probe+0x5c/0xd4 Add an error check in snd_soc_of_parse_card_name() to take care of this case and print out a message in case of error. Signed-off-by: Tushar Behera --- sound/soc/soc-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c4db07f..2e4bdc0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4391,9 +4391,16 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); int snd_soc_of_parse_card_name(struct snd_soc_card *card, const char *propname) { - struct device_node *np = card->dev->of_node; + struct device_node *np; int ret; + if (!card->dev) { + pr_err("card->dev is not set before calling %s\n", __func__); + return -EINVAL; + } + + np = card->dev->of_node; + ret = of_property_read_string_index(np, propname, 0, &card->name); /* * EINVAL means the property does not exist. This is fine providing