]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: audio-graph-card: fix refcount leak of cpu_ep in __graph_for_each_link()
authorWang Yufen <wangyufen@huawei.com>
Mon, 5 Dec 2022 08:15:27 +0000 (16:15 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:40 +0000 (11:41 +0100)
[ Upstream commit 6a4fc03bf6b097bd2ba2306d9d382fda856b4554 ]

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: c54552a4c119 ("ASoC: audio-graph-card: cleanup DAI link loop method - step2")
Signed-off-by: Wang Yufen <wangyufen@huawei.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/1670228127-13835-1-git-send-email-wangyufen@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/generic/audio-graph-card.c

index 96aa2c015572fd59398aa7210a9b8d7e4b628206..a96a7cd8af6ea9353f64b7cf70b460ef39486e28 100644 (file)
@@ -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;
                }