From patchwork Fri Jan 11 08:14:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rohit Kumar X-Patchwork-Id: 10757617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D69BA6C5 for ; Fri, 11 Jan 2019 10:43:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C086C29A40 for ; Fri, 11 Jan 2019 10:43:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B30C529AAE; Fri, 11 Jan 2019 10:43:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 079FE29A40 for ; Fri, 11 Jan 2019 10:43:09 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 4EB25266914; Fri, 11 Jan 2019 11:43:08 +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 A05F526791C; Fri, 11 Jan 2019 11:43:05 +0100 (CET) Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by alsa0.perex.cz (Postfix) with ESMTP id 148152668B2 for ; Fri, 11 Jan 2019 11:43:02 +0100 (CET) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 67376601DA; Fri, 11 Jan 2019 08:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1547194454; bh=/OPO2bL+6AsE5UNjnVY8VVBD/ui7edB4j6fJJK8wipc=; h=From:To:Cc:Subject:Date:From; b=HjDzA/E0aXPyL6r9sctAnZQHTE/w1cwqxyIvZhjuW0uma/LjJV+QbV1o+zkOkDlUl eLliDFsAwL3nv1Ug5PXw+g3PGisRm+UY7wg6Xu6gRx58BiomWDuiJnR1D3Y4LEXj5f dTHWPDwbS/kCweGM1kkerIhYIWktAmskwTKtBFb4= Received: from rohkumar-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rohitkr@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B466D601B4; Fri, 11 Jan 2019 08:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1547194454; bh=/OPO2bL+6AsE5UNjnVY8VVBD/ui7edB4j6fJJK8wipc=; h=From:To:Cc:Subject:Date:From; b=HjDzA/E0aXPyL6r9sctAnZQHTE/w1cwqxyIvZhjuW0uma/LjJV+QbV1o+zkOkDlUl eLliDFsAwL3nv1Ug5PXw+g3PGisRm+UY7wg6Xu6gRx58BiomWDuiJnR1D3Y4LEXj5f dTHWPDwbS/kCweGM1kkerIhYIWktAmskwTKtBFb4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B466D601B4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=rohitkr@codeaurora.org From: Rohit kumar To: plai@codeaurora.org, bgoswami@codeaurora.org, asishb@codeaurora.org, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, rohkumar@qti.qualcomm.com, srinivas.kandagatla@linaro.org, vinod.koul@linaro.org Date: Fri, 11 Jan 2019 13:44:02 +0530 Message-Id: <1547194442-1487-1-git-send-email-rohitkr@codeaurora.org> X-Mailer: git-send-email 1.9.1 Cc: Rohit kumar , Ajit Pandey Subject: [alsa-devel] [PATCH] ASoC: soc-core: Fix null pointer dereference in soc_find_component 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 From: Ajit Pandey soc_find_component() may lead to null pointer exception if both arguments i.e of_node and name is NULL. Add NULL check before calling soc_find_component(). Also fix some typos. Fixes: 8780cf1142a5 ("ASoC: soc-core: defer card probe until all component is added to list") Reported-by: Pierre-Louis Bossart Signed-off-by: Ajit Pandey Signed-off-by: Rohit kumar Tested-by: Pierre-Louis Bossart Signed-off-by: Pierre-Louis Bossart --- sound/soc/soc-core.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0934b36..df05fb8 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1131,11 +1131,13 @@ static int soc_init_dai_link(struct snd_soc_card *card, } /* - * Defer card registartion if platform dai component is not added to + * Defer card registration if platform dai component is not added to * component list. */ - if (!soc_find_component(link->platform->of_node, link->platform->name)) - return -EPROBE_DEFER; + if (link->platform->of_node || link->platform->name) + if (!soc_find_component(link->platform->of_node, + link->platform->name)) + return -EPROBE_DEFER; /* * CPU device may be specified by either name or OF node, but @@ -1150,11 +1152,12 @@ static int soc_init_dai_link(struct snd_soc_card *card, } /* - * Defer card registartion if cpu dai component is not added to + * Defer card registration if cpu dai component is not added to * component list. */ - if (!soc_find_component(link->cpu_of_node, link->cpu_name)) - return -EPROBE_DEFER; + if (link->cpu_of_node || link->cpu_name) + if (!soc_find_component(link->cpu_of_node, link->cpu_name)) + return -EPROBE_DEFER; /* * At least one of CPU DAI name or CPU device name/node must be