Skip to content

Commit 2e92617

Browse files
Srinivas Kandagatlabroonie
authored andcommitted
ASoC: qcom: q6apm: fix NULL pointer dereference in graph_callback
When q6apm_free_fragments() is called it frees rx_data.buf/tx_data.buf and sets them to NULL under graph->lock. A late DSP buffer-done response can race with this: graph_callback() passes the !graph->ar_graph guard (not yet NULL), acquires the lock, but then dereferences a now-NULL buf pointer to read buf[token].phys, crashing at virtual address 0x10. Add a NULL check for buf inside the mutex-protected section in both the write-done (DATA_CMD_RSP_WR_SH_MEM_EP_DATA_BUFFER_DONE_V2) and read-done (DATA_CMD_RSP_RD_SH_MEM_EP_DATA_BUFFER_V2) handlers and bail out cleanly if buffers have already been freed. This problem is only shown up recently while apr bus was updated to process the commands per service rather from single global queue. Fixes: 5477518 ("ASoC: qdsp6: audioreach: add q6apm support") Cc: Stable@vger.kernel.org Assisted-by: Claude:claude-4-6-sonnet Reported-by: Val Packett <val@packett.cool> Closes: https://lore.kernel.org/all/133ced18-1aa9-475d-80d8-6120678bdde4@packett.cool/ Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Link: https://patch.msgid.link/20260616170257.9381-1-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4346d91 commit 2e92617

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

sound/soc/qcom/qdsp6/q6apm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,10 @@ static int graph_callback(const struct gpr_resp_pkt *data, void *priv, int op)
587587
token = hdr->token & APM_WRITE_TOKEN_MASK;
588588

589589
done = data->payload;
590+
if (!graph->rx_data.buf) {
591+
mutex_unlock(&graph->lock);
592+
break;
593+
}
590594
phys = graph->rx_data.buf[token].phys;
591595
mutex_unlock(&graph->lock);
592596
/* token numbering starts at 0 */
@@ -609,6 +613,10 @@ static int graph_callback(const struct gpr_resp_pkt *data, void *priv, int op)
609613
client_event = APM_CLIENT_EVENT_DATA_READ_DONE;
610614
mutex_lock(&graph->lock);
611615
rd_done = data->payload;
616+
if (!graph->tx_data.buf) {
617+
mutex_unlock(&graph->lock);
618+
break;
619+
}
612620
phys = graph->tx_data.buf[hdr->token].phys;
613621
mutex_unlock(&graph->lock);
614622
/* token numbering starts at 0 */

0 commit comments

Comments
 (0)