Skip to contentSkip to conversation

ASoC: qcom: q6afe: do not report the unvote response as unknown

PATCH New Riccardo Mereu 2 participants 2 messages Dec 1

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: qcom: q6afe: do not report the unvote response as unknown

From: Riccardo Mereu <[email protected]>

q6afe_unvote_lpass_core_hw() sends AFE_CMD_REMOTE_LPASS_CORE_HW_DEVOTE_REQUEST and does not wait for the answer. The DSP acknowledges the request with a basic response, which the callback does not expect, so every unvote logs

qcom-q6afe aprsvc:service:4:4: Unknown cmd 0x100f6

This happens each time an LPASS codec macro is runtime suspended, that is after every use of the codec path.

Accept the response and ignore it. A failed unvote is still reported through the status check above the switch.

Fixes 55e07531d922 ("ASoC: q6dsp: q6afe: add lpass hw voting support")
---
 sound/soc/qcom/qdsp6/q6afe.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/qcom/qdsp6/q6afe.c +3 -0
index 4f7b706c77b5..4b2620cb9c4a 100644
@@ -1038,6 +1038,9 @@ static int q6afe_callback(struct apr_device *adev, const struct apr_resp_pkt *da
 				wake_up(&afe->wait);
 			}
 			break;
+		case AFE_CMD_REMOTE_LPASS_CORE_HW_DEVOTE_REQUEST:
+			/* nobody waits for the unvote to be acknowledged */
+			break;
 		default:
 			dev_err(afe->dev, "Unknown cmd 0x%x\n",	res->opcode);
 			break;
Signature · 16 lines
2.56.1


-- 





Privacy and Confidentiality Notice: This email and all attachments are 
confidential and for the designated recipient(s) only. They may also be 
privileged. If you are not the intended recipient or among the intended 
recipients, you may not use, read, retransmit, disseminate, store/copy the 
information in any medium or take any action in reliance upon it. Please 
notify the sender that you have received it in error and immediately delete 
the entire communication, including any attachments.
#1 lore raw
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] soc: qcom: apr: uninitialized…

Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [Critical] soc: qcom: apr: uninitialized pointer deref in apr_do_rx_callback() [1]
--

commit cd38bd3ad96610d53840f172cb39125a91b67488
Author: Riccardo Mereu <[email protected]>

ASoC: qcom: q6afe: do not report the unvote response as unknown

This commit adds a case for AFE_CMD_REMOTE_LPASS_CORE_HW_DEVOTE_REQUEST in q6afe_callback() so that asynchronous unvote acknowledgements from the DSP are ignored instead of logged as unknown commands.

Quoted 5 lines
sound/soc/qcom/qdsp6/q6afe.c +0 -0
index 4f7b706c77b5d..4b2620cb9c4a7 100644

sound/soc/qcom/qdsp6/q6afe.c static int q6afe_callback(struct apr_device *adev, const struct apr_resp_pkt *da · line 1046

Quoted 9 lines
sound/soc/qcom/qdsp6/q6afe.c +3 -0
@@ -1038,6 +1038,9 @@ static int q6afe_callback(struct apr_device *adev, const struct apr_resp_pkt *da
 				wake_up(&afe->wait);
 			}
 			break;
+		case AFE_CMD_REMOTE_LPASS_CORE_HW_DEVOTE_REQUEST:
+			/* nobody waits for the unvote to be acknowledged */
+			break;
 		default:
 			dev_err(afe->dev, "Unknown cmd 0x%x\n",	res->opcode);
 			break;

[Severity: Critical]
This problem wasn't introduced by this patch, but can q6afe_callback() dereference an uninitialized data->payload pointer via res [1]?

In apr_do_rx_callback(), hdr->pkt_size and hdr_size are unsigned 16-bit integers, so a malformed packet with hdr_size > hdr->pkt_size produces a negative resp.payload_size and leaves the stack pointer resp.payload uninitialized:

drivers/soc/qcom/apr.c:apr_do_rx_callback() {
    ...
	resp.payload_size = hdr->pkt_size - hdr_size;
	...
	if (resp.payload_size > 0)
		resp.payload = buf + hdr_size;

	adrv->callback(adev, &resp);
    ...
}

Because q6afe_callback() only checks if (!data->payload_size), a negative payload_size passes that check and res = data->payload is dereferenced.

[1] https://sashiko.dev/#/bug/linux-82d40745-1593-4c20-8432-d86099836525

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1