From patchwork Tue Jun 18 05:28:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11000927 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 60E511395 for ; Tue, 18 Jun 2019 05:29:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AAFC28699 for ; Tue, 18 Jun 2019 05:29:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3629028A11; Tue, 18 Jun 2019 05:29:17 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7672D28699 for ; Tue, 18 Jun 2019 05:29:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B5044170E; Tue, 18 Jun 2019 07:28:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B5044170E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1560835754; bh=o7OIJn0kzrFvgdJNsrkpD3N+Zcc1TiZyUiuSTemeEAM=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=A5IAFWN7zNgap0IOccfGeDWxMRCkYsxmxWqrJdMhDdL5WKugQFhpnTi8mDAzP12Wl S9iG7cZ5D938o/JLsOtuRYWEz2FcKXOG35qGIG4R4Jq0PnXanel7D+O8Ogkw1mFpj3 l1neyywI1xXhM26nsrJlCmYCYNB+bZSHbhCqoPR0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3BE61F896DB; Tue, 18 Jun 2019 07:28:24 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 54BAFF8971C; Tue, 18 Jun 2019 07:28:22 +0200 (CEST) Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 37BE8F8075C for ; Tue, 18 Jun 2019 07:28:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 37BE8F8075C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VuEodqM3" Received: by mail-pg1-x543.google.com with SMTP id w10so2372747pgj.7 for ; Mon, 17 Jun 2019 22:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=SqAd1fx2aqjUroAge2OaNB4tSLlvMkP+JhWERXOSN8Y=; b=VuEodqM3GEhgspN5BcSZBejRWyu1yfMzsvbt/tZcCt5AtPf01DDmMcr/YxPt5la51Y eAazo1sgyFm7hHAzmylz7IJwsHgTOpM5k1si7TJ3FbDsRl6PPeJHejJL0OEIt4gS1GKH jR0XlMVF4O6H8x0vXenyxoUWmPaZQPyQb/Q46CfiDuoDd4AejRu2OH2TcvcoLt1KVvXz hUTwDSqW+gWtikzfUEbdnp2rkDshNdXzeKLjxt1jXI6h6gfIJ88g9KwpGLNLUDwgO1Hu R3Dd1X0fhutxGN+CDAGj/KHsrlAQKUqMMf725VQBhO+S4DbDoMz4CoqO6L9Amo24rp2K RHZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SqAd1fx2aqjUroAge2OaNB4tSLlvMkP+JhWERXOSN8Y=; b=qDb/DEgIHOobVQMEiVrkOC985IHZzVDAu4I74zJWSWNW1GLUyqZY/0y9A5hM0r79wB ThgkoStnj09kRdO1at+a1jo87p0mJ7MWVWLVIfUObdPKW3GnHdhPubMSLqRI9u0yhk2T NcL23a2JupdQAHFZOyCcWO5/lXX4j7Rl/sQQBASEoYqpDckaJHmjF8jc1nKMUCQnqAnx TQ7vdpUTe5ZhUCDXFDfsaHqmxZbFJ5cp/wQiWknp/+JbJlFtVAnApiZhboQuBfvZ95zv Ri3ZIBd8gr+m/RX7x7czy/LdB6SjmQbzy3oBeZN0tbplX75yPDLv6qWEvBRdYUYD96mT pdeg== X-Gm-Message-State: APjAAAXJMFTWv4MBky8X9BlBLpvKaCeH7t8mAQzvxhlEG2bA+W+NEQxT SSybo9Xfv/GjL/GGEQXbT83WQw== X-Google-Smtp-Source: APXvYqz4ODTWIjG3AqGUUeq6vsPQMClqM7BcnsAUOQ3cPzIUXZ5ipOaid/o/JhY/P+BpjDaxGb6eZQ== X-Received: by 2002:a63:4a1f:: with SMTP id x31mr972877pga.150.1560835696219; Mon, 17 Jun 2019 22:28:16 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id 188sm13934085pfg.11.2019.06.17.22.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 22:28:15 -0700 (PDT) From: Bjorn Andersson To: Patrick Lai , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Date: Mon, 17 Jun 2019 22:28:13 -0700 Message-Id: <20190618052813.32523-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 Cc: linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla , linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] ASoC: qcom: common: Fix NULL pointer in of parser X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP A snd_soc_dai_link_component is allocated and associated with the first link, so when the code tries to assign the of_node of the second link's "cpu" member it dereferences a NULL pointer. Fix this by moving the allocation and assignement of snd_soc_dai_link_components into the loop, giving us one pair per link. Fixes: 1e36ea360ab9 ("ASoC: qcom: common: use modern dai_link style") Signed-off-by: Bjorn Andersson Acked-by: Srinivas Kandagatla --- sound/soc/qcom/common.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c index c7a878507220..97488b5cc515 100644 --- a/sound/soc/qcom/common.c +++ b/sound/soc/qcom/common.c @@ -42,17 +42,17 @@ int qcom_snd_parse_of(struct snd_soc_card *card) card->num_links = num_links; link = card->dai_link; - dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL); - if (!dlc) - return -ENOMEM; + for_each_child_of_node(dev->of_node, np) { + dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL); + if (!dlc) + return -ENOMEM; - link->cpus = &dlc[0]; - link->platforms = &dlc[1]; + link->cpus = &dlc[0]; + link->platforms = &dlc[1]; - link->num_cpus = 1; - link->num_platforms = 1; + link->num_cpus = 1; + link->num_platforms = 1; - for_each_child_of_node(dev->of_node, np) { cpu = of_get_child_by_name(np, "cpu"); platform = of_get_child_by_name(np, "platform"); codec = of_get_child_by_name(np, "codec");