Commit e54f128b authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: audio-graph-card2: call of_node_get() before of_get_next_child()

commit c6f597bc ("ASoC: audio-graph-card2: remove unneeded
of_node_get()") removed of_node_get(), but it need to keep original
reference, so of_node_get() itself is needed.

Because of_get_next_child() will call of_node_put() inside, if the
reference count dropped to zero, then of_node_get() after that will be
use afer free. Need to call of_node_get() *before* that.

Fixes: c6f597bc ("ASoC: audio-graph-card2: remove unneeded of_node_get()")
Link: https://lore.kernel.org/r/f930862e-9d30-4ea3-b3e7-b4b4f411f6d1@moroto.mountainReported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875xvmqzs8.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent acfff66e
...@@ -1197,7 +1197,7 @@ static int graph_count_c2c(struct simple_util_priv *priv, ...@@ -1197,7 +1197,7 @@ static int graph_count_c2c(struct simple_util_priv *priv,
{ {
struct device_node *ports = of_get_parent(lnk); struct device_node *ports = of_get_parent(lnk);
struct device_node *port0 = lnk; struct device_node *port0 = lnk;
struct device_node *port1 = of_get_next_child(ports, lnk); struct device_node *port1 = of_get_next_child(ports, of_node_get(lnk));
struct device_node *ep0 = port_to_endpoint(port0); struct device_node *ep0 = port_to_endpoint(port0);
struct device_node *ep1 = port_to_endpoint(port1); struct device_node *ep1 = port_to_endpoint(port1);
struct device_node *codec0 = of_graph_get_remote_port(ep0); struct device_node *codec0 = of_graph_get_remote_port(ep0);
......
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