From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DD8C1875 for ; Wed, 28 Dec 2022 15:59:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91477C433D2; Wed, 28 Dec 2022 15:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672243163; bh=D5xTLGtfH6tIVUWRU4u3V1+jEB8UI/2PGD0znMVXnKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bZ3HmBy5ZIz82cVhVscvL+14ikTMQb4NhN3B55iXU/kUfuso5B1GGo0SoLaTifKCW hN9pto9x9fXOuifJ7Qi/wCr0F7qMFAZW4uq8FxkmdOzdVlxQa4cgaf6DU9ImKAQ0xE mMvFddv7IBqQUu+Zl/oamC0lAqDQ2qaL3vezMWJg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wang Yufen , Kuninori Morimoto , Mark Brown , Sasha Levin Subject: [PATCH 5.15 690/731] ASoC: audio-graph-card: fix refcount leak of cpu_ep in __graph_for_each_link() Date: Wed, 28 Dec 2022 15:43:17 +0100 Message-Id: <20221228144316.465477813@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144256.536395940@linuxfoundation.org> References: <20221228144256.536395940@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Wang Yufen [ Upstream commit 8ab2d12c726f0fde0692fa5d81d8019b3dcd62d0 ] The of_get_next_child() returns a node with refcount incremented, and decrements the refcount of prev. So in the error path of the while loop, of_node_put() needs be called for cpu_ep. Fixes: fce9b90c1ab7 ("ASoC: audio-graph-card: cleanup DAI link loop method - step2") Signed-off-by: Wang Yufen Acked-by: Kuninori Morimoto Link: https://lore.kernel.org/r/1670228127-13835-1-git-send-email-wangyufen@huawei.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/generic/audio-graph-card.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 28cbcdb56857..89814f68ff56 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -483,8 +483,10 @@ static int __graph_for_each_link(struct asoc_simple_priv *priv, of_node_put(codec_ep); of_node_put(codec_port); - if (ret < 0) + if (ret < 0) { + of_node_put(cpu_ep); return ret; + } codec_port_old = codec_port; } -- 2.35.1