ASoC: qcom: q6apm: initialize graph refcount before publishing
Subsystems (4)
PATCH 1/1 ASoC: qcom: q6apm: initialize graph refcount before publishing
q6apm_get_audioreach_graph() inserts a newly allocated graph into graph_idr before initializing its refcount. Another caller looking up the same graph id can find the graph and call kref_get() before kref_init(). Initialize the refcount before publishing the graph in the IDR.
--- sound/soc/qcom/qdsp6/q6apm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/qcom/qdsp6/q6apm.c +1 -2
@@ -65,6 +65,7 @@ static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, ui graph->apm = apm; graph->info = info; graph->id = graph_id; +kref_init (&graph->refcount); graph->graph =audioreach_alloc_graph_pkt (apm, info);if (IS_ERR (graph->graph)) {
@@ -85,8 +86,6 @@ static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, ui }mutex_unlock (&apm->lock); -kref_init (&graph->refcount); -q6apm_send_cmd_sync (apm, graph->graph,0 );return graph;
Signature · 1 line
2.51.0
Srinivas Kandagatla
maintainerQuoted 15 lines · Ruoyu Wang
q6apm_get_audioreach_graph()inserts a newly allocated graph intograph_idrbefore initializing its refcount. Another caller looking up the same graph id can find the graph and callkref_get()beforekref_init(). Initialize the refcount before publishing the graph in the IDR.Signed-off-by Ruoyu Wang <[email protected]>--- sound/soc/qcom/qdsp6/q6apm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)sound/soc/qcom/qdsp6/q6apm.c +0
-0
sound/soc/qcom/qdsp6/q6apm.c static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, ui · line 69
Quoted 5 lines
sound/soc/qcom/qdsp6/q6apm.c +1
-0@@ -65,6 +65,7 @@ static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, ui graph->apm = apm; graph->info = info; graph->id = graph_id; +kref_init (&graph->refcount);
this is going to break the error handing further down the code.
--srini
Quoted 11 lines
sound/soc/qcom/qdsp6/q6apm.c +0
-2graph->graph =audioreach_alloc_graph_pkt (apm, info);if (IS_ERR (graph->graph)) {@@ -85,8 +86,6 @@ static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, ui }mutex_unlock (&apm->lock); -kref_init (&graph->refcount); -q6apm_send_cmd_sync (apm, graph->graph,0 );return graph;