Re: [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams
From: Mark Brown
Date: Tue Mar 31 2026 - 07:32:24 EST
On Tue, Mar 31, 2026 at 08:12:25AM +0300, Péter Ujfalusi wrote:
> On 30/03/2026 23:11, Mark Brown wrote:
> > Actually already we have a guard preventing userspace from doing an
> > avail() when we're unconfigured but we do it after we've called down
> > into the driver which is less than ideal. I think that's because we
> > also check for XRUN and the availability check might cause us to notice
> > that we're in a bad state for that.
> I don't see how the avail path checks for XRUN and if the drivers
> supposed to do that, I'm not even sure if XRUN is possible with compress..
Yeah, I was hoping there was something in driver code there but didn't
actually check. You should at least be able to get a buffer overrun
with compressed streams, and even if I'd expect most things to fill
silence you can undderrun which would be bad for applications like music
playback.
> I did noted that the avail have the state check reversed, making it
> ineffective.
> The other point is that any return code from the driver's pointer
> callback is ignored by the core, the return value of
> stream->ops->pointer() is not even captured, it could be void.
> Looks like a design choice, but I cannot say.
I suppose it's easier to have the error reporting in the drivers in case
you want it later.
> fwiw, the same check should be added to sound/soc/qcom/qdsp6/q6apm-dai.c
> as it does div with prtd->pcm_size (q6apm_dai_compr_pointer), which is
> only initialized in set_params.
Ack, I hadn't looked at any other drivers. I was actually going to send
out the core patch but even so some defence in depth would make me
happier.
Attachment:
signature.asc
Description: PGP signature