Skip to content

Commit df5b4ac

Browse files
Jianglei Niebroonie
authored andcommitted
ASoC: qdsp6: fix potential memory leak in q6apm_get_audioreach_graph()
q6apm_get_audioreach_graph() allocates a memory chunk for graph->graph with audioreach_alloc_graph_pkt(). When idr_alloc() fails, graph->graph is not released, which will lead to a memory leak. We can release the graph->graph with kfree() when idr_alloc() fails to fix the memory leak. Signed-off-by: Jianglei Nie <[email protected]> Reviewed-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 1c4f29e commit df5b4ac

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

sound/soc/qcom/qdsp6/q6apm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, ui
7575
id = idr_alloc(&apm->graph_idr, graph, graph_id, graph_id + 1, GFP_KERNEL);
7676
if (id < 0) {
7777
dev_err(apm->dev, "Unable to allocate graph id (%d)\n", graph_id);
78+
kfree(graph->graph);
7879
kfree(graph);
7980
mutex_unlock(&apm->lock);
8081
return ERR_PTR(id);

0 commit comments

Comments
 (0)