From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA998472531; Tue, 21 Jul 2026 19:52:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663526; cv=none; b=iuuy6nHR9lHpnA9hHlkwvGGs1BLbAnZenlIn9MsuuPIr7hspeJm8djn/LPzfUphQFrPWweedQwHM+VkGycRQJP/SjVetbyG7TDhewE3LSVCBPf1ZRRjdSiAU/I+y6ZR/XvVMQsQE7MAZB2aExrrJwI0hFb78h5xxnBInF03sKyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663526; c=relaxed/simple; bh=w4NMzQCs9OXXfvLdOqo7DTXmNOHPMZMl1zCB6QWO50M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hKd5gfLlMIF9sSVgP7uw7SkAtecIRMNY+41bIi92WVbV6GuAxke1IfFOzpr+g4cA27Dab9sKfcQ9AqqYSwQt71Q5fG4CduTSmP+mXXTZwGqbhEmiXMvzZkHCThnBwZHyCLAkVLKrpIzoYqIf0bEXooXbyg7XNe8d+prajmxLNeU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=do5Imwr8; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="do5Imwr8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 264D21F000E9; Tue, 21 Jul 2026 19:52:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784663525; bh=fxVN6jRZOzjP0bf7jK61BuqP2vMMGJ2bsaDfRbua2gk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=do5Imwr8qIr2SHzwqNhkgaa1IXqc5peHdNk37QEZgatbgNqag3SVgJngEXMpdK93D q2iIMA3rcwGlsJQLHaaGwQYEcv9oh1zIxoRyQ4qotsRcDekM1RTIKzDW+zEUZS+MFO Sy7bWb+x8Rb+4Cq2jn9WvIcNc3tGipx/1JSGEJZg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stable@vger.kernel.org, Val Packett , Srinivas Kandagatla , Mark Brown Subject: [PATCH 6.12 0856/1276] ASoC: qcom: q6apm: fix NULL pointer dereference in graph_callback Date: Tue, 21 Jul 2026 17:21:39 +0200 Message-ID: <20260721152505.206294018@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivas Kandagatla commit 2e9261761b35f0b67b7487688cd1365f535be0b3 upstream. 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: 5477518b8a0e ("ASoC: qdsp6: audioreach: add q6apm support") Cc: Stable@vger.kernel.org Assisted-by: Claude:claude-4-6-sonnet Reported-by: Val Packett Closes: https://lore.kernel.org/all/133ced18-1aa9-475d-80d8-6120678bdde4@packett.cool/ Signed-off-by: Srinivas Kandagatla Link: https://patch.msgid.link/20260616170257.9381-1-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/qcom/qdsp6/q6apm.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -533,6 +533,10 @@ static int graph_callback(struct gpr_res token = hdr->token & APM_WRITE_TOKEN_MASK; done = data->payload; + if (!graph->rx_data.buf) { + mutex_unlock(&graph->lock); + break; + } phys = graph->rx_data.buf[token].phys; mutex_unlock(&graph->lock); /* token numbering starts at 0 */ @@ -567,6 +571,10 @@ static int graph_callback(struct gpr_res client_event = APM_CLIENT_EVENT_DATA_READ_DONE; mutex_lock(&graph->lock); rd_done = data->payload; + if (!graph->tx_data.buf) { + mutex_unlock(&graph->lock); + break; + } phys = graph->tx_data.buf[hdr->token].phys; mutex_unlock(&graph->lock); /* token numbering starts at 0 */