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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6248C46467 for ; Mon, 16 Jan 2023 16:39:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233468AbjAPQjE (ORCPT ); Mon, 16 Jan 2023 11:39:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233467AbjAPQin (ORCPT ); Mon, 16 Jan 2023 11:38:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A03F427D56 for ; Mon, 16 Jan 2023 08:27:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D05A6B8107D for ; Mon, 16 Jan 2023 16:27:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30053C433D2; Mon, 16 Jan 2023 16:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673886448; bh=xLNK1PvoJh0Dx4+icM8fpYqF4BejcDZQqWp4O/lNUEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cIn3M9X5JJEGHSzjc0wQN7nfsi/BRJmyh5Pdi/MJP97WMuiIPomYXyZ71Ra+YjiY6 O4s2ICbFZujsqYjdhiz1/xc2/SNbOaQ4cSN6oShyvtKxYdzT36TEA46ARqhczlcCP1 /2F0UrNY/8mUZ6IJMOndpIzSQQiyV7F0DOfWKTwM= 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.4 434/658] ASoC: audio-graph-card: fix refcount leak of cpu_ep in __graph_for_each_link() Date: Mon, 16 Jan 2023 16:48:42 +0100 Message-Id: <20230116154929.411118012@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154909.645460653@linuxfoundation.org> References: <20230116154909.645460653@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 96aa2c015572..a96a7cd8af6e 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -466,8 +466,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