Skip to content

Commit

Permalink
ASoC: audio-graph-card2: call of_node_get() before of_get_next_child()
Browse files Browse the repository at this point in the history
commit c6f597b ("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: c6f597b ("ASoC: audio-graph-card2: remove unneeded of_node_get()")
Link: https://lore.kernel.org/r/[email protected]
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Kuninori Morimoto <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
morimoto authored and broonie committed May 10, 2024
1 parent acfff66 commit e54f128
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/soc/generic/audio-graph-card2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *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 *ep1 = port_to_endpoint(port1);
struct device_node *codec0 = of_graph_get_remote_port(ep0);
Expand Down

0 comments on commit e54f128

Please sign in to comment.