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 D427735C6BC; Tue, 21 Jul 2026 21:38:56 +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=1784669937; cv=none; b=RD6gCNX1yXBSpOzfhYSfFnKsfdRRyphMDL6iSFa1Or0bRHJD+M5syGCV6Ixyyy4yvdE2rzej8iGCyjaofqbxWs/58nwnKMapCv3Qudu7B1Lg6pV4FgVdUnCGRBD3TkGZthlXSfYuuSdksCDx/MfEd07DJlCBxJGmc8YeyS0psG8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669937; c=relaxed/simple; bh=T3GSBG99dExKAwhgJkfRDCfexwNxVbP301vJSzFrkRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pdLyEh/ST/FHUTwABgp92uaiTYErXpKwR/zR1d62zAR80/mJRIdAA+flfzAQlhCNQvr1ktPYxjBR55CA4YYUd1QmRfoeHbmKOArMoY8Cxb/y3Ay4GVxyKPsFaEXxBKtR+l0QJ2mINv2C02eZXok31Q7AsiFB3nwa7Si7Fv8LLyI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yuh8ULgT; 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="yuh8ULgT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8CD61F000E9; Tue, 21 Jul 2026 21:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784669936; bh=H8KaYLuuVZOx5u9WkBCITyTeitZEp9tX3DRKNpvECuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yuh8ULgTt9tseOOCTBcEO1Tp3iLXLEAoRVJ6wQ07AGm/fyYrOror7XnpJJj/oF66o iOUAStZ9rirpnSrCMQWO2U7OjvcEMyZjEPPvCtOZWjmiaecFESvN+yshFzP62Uq+2I vFfvRzrU9FFQqOpusBjqy9qmodomoE9KRN0zMKMs= 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.1 0741/1067] ASoC: qcom: q6apm: fix NULL pointer dereference in graph_callback Date: Tue, 21 Jul 2026 17:22:22 +0200 Message-ID: <20260721152441.156229995@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@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.1-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 @@ -524,6 +524,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); @@ -557,6 +561,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);