Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Ruoyu Wang <ruoyuw560@gmail.com>
To: Srinivas Kandagatla <srini@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] ASoC: qcom: q6apm: initialize graph refcount before publishing
Date: Thu, 18 Jun 2026 02:21:50 +0800	[thread overview]
Message-ID: <20260617182150.959983-1-ruoyuw560@gmail.com> (raw)

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.

Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 sound/soc/qcom/qdsp6/q6apm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c
index 2e5b25b8d00fd..1953e8ca8777b 100644
--- a/sound/soc/qcom/qdsp6/q6apm.c
+++ b/sound/soc/qcom/qdsp6/q6apm.c
@@ -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;
-- 
2.51.0


             reply	other threads:[~2026-06-17 18:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17 18:21 Ruoyu Wang [this message]
2026-07-16 21:19 ` [PATCH] ASoC: qcom: q6apm: initialize graph refcount before publishing Srinivas Kandagatla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260617182150.959983-1-ruoyuw560@gmail.com \
    --to=ruoyuw560@gmail.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=srini@kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox