Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5649906img; Wed, 27 Mar 2019 12:26:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJbVtVfwhpIU2SrA+ZgWbFlWhX+OGqrWkzAGzwTbNwPDDxsHQLV78YKpEq7/s0nlyRs7vL X-Received: by 2002:a17:902:e113:: with SMTP id cc19mr39924002plb.179.1553714779879; Wed, 27 Mar 2019 12:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714779; cv=none; d=google.com; s=arc-20160816; b=sQe064LzyuWY7wp3NZM2kkmK637C5pJ5NFrll79Henb2hoRjIg0I5LoqLpj7FZmb0w H7h0RWNEUwxQqJt55/hltLjGMKlTgeUKv/ValhQ1MxhfvCrOUL0OaGsdEdgWobeVV6DJ RYy+ujTBgt5t5CFZqYJfpWo3DrGqugDKNNwNZs7w5yrOYrepVTMkOmb9U3XW9Cz46mYE L9BkpYSTX7RclfiZ3XNgFt/AUIxdhJvwK4C0Q6+pUx76cRdcWhib95G/JlW8Iwh4amCX hfYiDcSek1bTG4mwMxbPPnmTrae4k2Up5sgwNgA15DklQpIxa43d93AgHaFO+c+fSzpZ r4/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JGZCLr2POr+JAV917QWBc2StK+LHi/+fAB90BB2kuSQ=; b=uWwqr9cI5cWHIZbRyXmN/5zj+8WAjZelTA8WftWNBwSE99s31ZqLtnEDYIax0HcL9I eKpsw74pquvoOWMWrWUCHXkeAMfNiLvXfThfI+QITild/XqxedPsbAWVexH6s5mcTq7t onfJBRgtO9g0/IJ1ol5q05UphLM491uzZGY/86cz6VTAPbwABQAWFVYJVPPgQgbD8Nf6 vUvek7TG7jPP3jQe+aW8BQ+HP2241mCNiem/e1BKof/n4cynVRG0m+SgKHD5PsBrpURb bDs2SdQuagy/Z98d66Fk0ooceN03pCqRsPXXUKWlozD5tr4zeRizvNcwc05DjZUHFLgz G3Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DgMeaQoI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i18si18361708pfa.205.2019.03.27.12.26.04; Wed, 27 Mar 2019 12:26:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DgMeaQoI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728843AbfC0SFQ (ORCPT + 99 others); Wed, 27 Mar 2019 14:05:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:46258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387608AbfC0SFM (ORCPT ); Wed, 27 Mar 2019 14:05:12 -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 0F2D32075C; Wed, 27 Mar 2019 18:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709911; bh=eO+FsWqCgcDGLQwkANGQvPR+AWgXIpvlND091seKMpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DgMeaQoI0zIrI1UE5rlEqCmixDHztqnMS07/g9NU7B1TIa69CN6/W/4ARI0F8d5mX PvD0PlrmAknHfOP4BGPaAFY1C1DZ/aT+vhKSa95EXS9zWy2uDSc8FqW1PpbE3+pk2i n7OHl15Xfh9y3HBzBFZ1mXMPqJMm0NT54twqksfQ= 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 5.0 107/262] ASoC: qcom: Fix of-node refcount unbalance in apq8016_sbc_parse_of() Date: Wed, 27 Mar 2019 13:59:22 -0400 Message-Id: <20190327180158.10245-107-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 1dd23bba1bed..4b559932adc3 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -164,41 +164,52 @@ 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; } 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_link_codecs(dev, codec, link); if (ret < 0) { dev_err(card->dev, "error getting codec dai name\n"); - return ERR_PTR(ret); + goto error; } link->platform_of_node = link->cpu_of_node; 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 const struct snd_soc_dapm_widget apq8016_sbc_dapm_widgets[] = { -- 2.19.1