[PATCH] ASoC: qcom: qdsp6: Reject pointer operations on unconfigured streams

Mark Brown posted 1 patch an hour ago
sound/soc/qcom/qdsp6/q6apm-dai.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] ASoC: qcom: qdsp6: Reject pointer operations on unconfigured streams
Posted by Mark Brown an hour ago
The QDSP6 driver reports the current byte offset by dividing the current
copied data total by pcm_size, but pcm_size is only configured as part of
set_params() so if we manage to do a pointer operation before that happens
we will divide by 0. There is no sensible reason to do so, add an error
check for robustness.

Reported-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/qcom/qdsp6/q6apm-dai.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c
index 168c166c960d..833d4782c68f 100644
--- a/sound/soc/qcom/qdsp6/q6apm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6apm-dai.c
@@ -582,6 +582,9 @@ static int q6apm_dai_compr_pointer(struct snd_soc_component *component,
 	guard(spinlock_irqsave)(&prtd->lock);
 	tstamp->copied_total = prtd->copied_total;
 	temp_copied_total = tstamp->copied_total;
+
+	if (!prtd->pcm_size)
+		return -EINVAL;
 	tstamp->byte_offset = do_div(temp_copied_total, prtd->pcm_size);
 
 	return 0;

---
base-commit: 7aaa8047eafd0bd628065b15757d9b48c5f9c07d
change-id: 20260331-asoc-qcom-qdsp6-robustness-81b98c0dbe0b

Best regards,
--  
Mark Brown <broonie@kernel.org>