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 B63D41C08 for ; Wed, 28 Dec 2022 16:47:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32C55C433D2; Wed, 28 Dec 2022 16:47:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672246032; bh=Rp0Vfs28a9n2e460dB6yCVQtP91ApgOF/Vejm3x8e+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wdg80zCsq53KFFlPMVEqb3d58UcIRocNiHlQCPedotVqgXcjFDS0OAx6PXHsBXG2Q iNrxb2MbM+AsYb6zw1PPpr8XxMzDLGRNV+h3uoro/nUzbx8ggu36/AbERlUjEIGuVi i07Ze0AHuQ0FqELssABJBBPPOFKg+itPRT+Sg3HY= 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 6.0 1001/1073] ASoC: audio-graph-card: fix refcount leak of cpu_ep in __graph_for_each_link() Date: Wed, 28 Dec 2022 15:43:09 +0100 Message-Id: <20221228144355.327821567@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144328.162723588@linuxfoundation.org> References: <20221228144328.162723588@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 b327372f2e4a..4e776c2a38a4 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -485,8 +485,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