Skip to content

Commit

Permalink
ASoC: audio-graph-card: fix an use-after-free in graph_get_dai_id()
Browse files Browse the repository at this point in the history
After calling of_node_put() on the node variable, it is still being
used, which may result in use-after-free.
Fix this issue by calling of_node_put() after the last usage.

Fixes: a0c426f ("ASoC: simple-card-utils: check "reg" property on asoc_simple_card_get_dai_id()")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Wen Yang <[email protected]>
Acked-by: Kuninori Morimoto <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
taskset authored and broonie committed Jul 10, 2019
1 parent aa2e362 commit c152f84
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sound/soc/generic/audio-graph-card.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static int graph_get_dai_id(struct device_node *ep)
struct device_node *endpoint;
struct of_endpoint info;
int i, id;
u32 *reg;
int ret;

/* use driver specified DAI ID if exist */
Expand All @@ -83,8 +84,9 @@ static int graph_get_dai_id(struct device_node *ep)
return info.id;

node = of_get_parent(ep);
reg = of_get_property(node, "reg", NULL);
of_node_put(node);
if (of_get_property(node, "reg", NULL))
if (reg)
return info.port;
}
node = of_graph_get_port_parent(ep);
Expand Down

0 comments on commit c152f84

Please sign in to comment.