From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5011C4360F for ; Wed, 27 Mar 2019 18:35:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9822020657 for ; Wed, 27 Mar 2019 18:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553711748; bh=XtLNk+7F3yKI42NxjKCYxEjfVRvUaikUKsDjQtSqi2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=evifsDq1GAhQBJQsEsO+C4IH8vPt3zOngJ4x7Bz4HL4r9xpe+krbRdxNAPGQBDtw9 UqOQ/dlbF63HNo1/teuHdvrVojOOdXIwYKqOLSeXIqitw4zv6IYZEbLrKcOwDTFUqg 72ywZa2Deu3Gn84bH0vriCpcTEplTVpBmtIRbBCk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403994AbfC0SYP (ORCPT ); Wed, 27 Mar 2019 14:24:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:43006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391166AbfC0SYJ (ORCPT ); Wed, 27 Mar 2019 14:24:09 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5E8062177E; Wed, 27 Mar 2019 18:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553711048; bh=XtLNk+7F3yKI42NxjKCYxEjfVRvUaikUKsDjQtSqi2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6KlwAzKUMZuTW07CwmKuCPQm6dgtn0+PfAbEdPjSoyiqUxpSkyVtdfmT8j+vyQf4 sLhWj7bQMcz/+pbP+9YT4/TizSakMWlW1lFXbpGiqd1LHSf7wnquieMf6S83KHMqxW VbNBw5XOV2etxDiVtVpDlfUoNLONpd0M7m9abP4A= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Patrick Lai , Banajit Goswami , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 4.4 27/63] ASoC: qcom: Fix of-node refcount unbalance in apq8016_sbc_parse_of() Date: Wed, 27 Mar 2019 14:22:47 -0400 Message-Id: <20190327182323.18577-27-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182323.18577-1-sashal@kernel.org> References: <20190327182323.18577-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai [ Upstream commit 8d1667200850f8753c0265fa4bd25c9a6e5f94ce ] The apq8016 driver leaves the of-node refcount at aborting from the loop of for_each_child_of_node() in the error path. Not only the iterator node of for_each_child_of_node(), the children nodes referred from it for codec and cpu have to be properly unreferenced. Fixes: bdb052e81f62 ("ASoC: qcom: add apq8016 sound card support") Cc: Patrick Lai Cc: Banajit Goswami Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/qcom/apq8016_sbc.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c index 1efdf0088ecd..886f2027e671 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -98,13 +98,15 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card) if (!cpu || !codec) { dev_err(dev, "Can't find cpu/codec DT node\n"); - return ERR_PTR(-EINVAL); + ret = -EINVAL; + goto error; } link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0); if (!link->cpu_of_node) { dev_err(card->dev, "error getting cpu phandle\n"); - return ERR_PTR(-EINVAL); + ret = -EINVAL; + goto error; } link->codec_of_node = of_parse_phandle(codec, "sound-dai", 0); @@ -116,13 +118,13 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card) ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name); if (ret) { dev_err(card->dev, "error getting cpu dai name\n"); - return ERR_PTR(ret); + goto error; } ret = snd_soc_of_get_dai_name(codec, &link->codec_dai_name); if (ret) { dev_err(card->dev, "error getting codec dai name\n"); - return ERR_PTR(ret); + goto error; } link->platform_of_node = link->cpu_of_node; @@ -132,15 +134,24 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card) ret = of_property_read_string(np, "link-name", &link->name); if (ret) { dev_err(card->dev, "error getting codec dai_link name\n"); - return ERR_PTR(ret); + goto error; } link->stream_name = link->name; link->init = apq8016_sbc_dai_init; link++; + + of_node_put(cpu); + of_node_put(codec); } return data; + + error: + of_node_put(np); + of_node_put(cpu); + of_node_put(codec); + return ERR_PTR(ret); } static int apq8016_sbc_platform_probe(struct platform_device *pdev) -- 2.19.1