Commit b2e77a92 authored by Wen Yang's avatar Wen Yang Committed by Greg Kroah-Hartman

ASoC: audio-graph-card: fix use-after-free in graph_for_each_link

[ Upstream commit 1bcc1fd6 ]

After calling of_node_put() on the codec_ep and codec_port variables,
they are still being used, which may result in use-after-free.
We fix this issue by calling of_node_put() after the last usage.

Fixes: fce9b90c ("ASoC: audio-graph-card: cleanup DAI link loop method - step2")
Signed-off-by: default avatarWen Yang <wen.yang99@zte.com.cn>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Link: https://lore.kernel.org/r/1562229530-8121-1-git-send-email-wen.yang99@zte.com.cnSigned-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent cbd7d2d8
......@@ -460,9 +460,6 @@ static int graph_for_each_link(struct graph_priv *priv,
codec_ep = of_graph_get_remote_endpoint(cpu_ep);
codec_port = of_get_parent(codec_ep);
of_node_put(codec_ep);
of_node_put(codec_port);
/* get convert-xxx property */
memset(&adata, 0, sizeof(adata));
graph_get_conversion(dev, codec_ep, &adata);
......@@ -482,6 +479,9 @@ static int graph_for_each_link(struct graph_priv *priv,
else
ret = func_noml(priv, cpu_ep, codec_ep, li);
of_node_put(codec_ep);
of_node_put(codec_port);
if (ret < 0)
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment