diff options
author | Wen Yang <wen.yang99@zte.com.cn> | 2019-07-10 03:25:09 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-07-10 11:33:57 -0400 |
commit | c152f8491a8d9a4b25afd65a86eb5e55e2a8c380 (patch) | |
tree | 9b14795fdc6b5dbca84e92b252d186e6c21902d9 /sound/soc/generic | |
parent | aa2e362cb6b3f5ca88093ada01e1a0ace8a517b2 (diff) |
ASoC: audio-graph-card: fix an use-after-free in graph_get_dai_id()
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: a0c426fe1433 ("ASoC: simple-card-utils: check "reg" property on asoc_simple_card_get_dai_id()")
Link: https://lore.kernel.org/r/1562743509-30496-5-git-send-email-wen.yang99@zte.com.cn
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/generic')
-rw-r--r-- | sound/soc/generic/audio-graph-card.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index bddfcfd7bedf..343ede8042c3 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c | |||
@@ -63,6 +63,7 @@ static int graph_get_dai_id(struct device_node *ep) | |||
63 | struct device_node *endpoint; | 63 | struct device_node *endpoint; |
64 | struct of_endpoint info; | 64 | struct of_endpoint info; |
65 | int i, id; | 65 | int i, id; |
66 | u32 *reg; | ||
66 | int ret; | 67 | int ret; |
67 | 68 | ||
68 | /* use driver specified DAI ID if exist */ | 69 | /* use driver specified DAI ID if exist */ |
@@ -83,8 +84,9 @@ static int graph_get_dai_id(struct device_node *ep) | |||
83 | return info.id; | 84 | return info.id; |
84 | 85 | ||
85 | node = of_get_parent(ep); | 86 | node = of_get_parent(ep); |
87 | reg = of_get_property(node, "reg", NULL); | ||
86 | of_node_put(node); | 88 | of_node_put(node); |
87 | if (of_get_property(node, "reg", NULL)) | 89 | if (reg) |
88 | return info.port; | 90 | return info.port; |
89 | } | 91 | } |
90 | node = of_graph_get_port_parent(ep); | 92 | node = of_graph_get_port_parent(ep); |