RE: [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured streams

From: Liao, Bard

Date: Thu Mar 26 2026 - 22:10:46 EST




> -----Original Message-----
> From: Mark Brown <broonie@xxxxxxxxxx>
> Sent: Thursday, March 26, 2026 10:53 PM
> To: Liam Girdwood <lgirdwood@xxxxxxxxx>; Peter Ujfalusi
> <peter.ujfalusi@xxxxxxxxxxxxxxx>; Bard Liao <yung-
> chuan.liao@xxxxxxxxxxxxxxx>; Ranjani Sridharan
> <ranjani.sridharan@xxxxxxxxxxxxxxx>; Daniel Baluta <daniel.baluta@xxxxxxx>;
> Kai Vehmanen <kai.vehmanen@xxxxxxxxxxxxxxx>; Pierre-Louis Bossart <pierre-
> louis.bossart@xxxxxxxxx>; Jaroslav Kysela <perex@xxxxxxxx>; Takashi Iwai
> <tiwai@xxxxxxxx>; Paul Olaru <paul.olaru@xxxxxxxxxxx>; Laurentiu Mihalcea
> <laurentiu.mihalcea@xxxxxxx>
> Cc: sound-open-firmware@xxxxxxxxxxxxxxxx; linux-sound@xxxxxxxxxxxxxxx;
> linux-kernel@xxxxxxxxxxxxxxx; Mark Brown <broonie@xxxxxxxxxx>;
> stable@xxxxxxxxxxxxxxx
> Subject: [PATCH] ASoC: SOF: Don't allow pointer operations on unconfigured
> streams
>
> When reporting the pointer for a compressed stream we report the current
> I/O frame position by dividing the position by the number of channels
> multiplied by the number of container bytes. These values default to 0 and
> are only configured as part of setting the stream parameters so this allows
> a divide by zero to be configured. Validate that they are non zero,
> returning an error if not
>
> Fixes: c1a731c71359 ("ASoC: SOF: compress: Add support for computing
> timestamps")
> Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> ---
> sound/soc/sof/compress.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c
> index 96570121aae0..90f056eae1c3 100644
> --- a/sound/soc/sof/compress.c
> +++ b/sound/soc/sof/compress.c
> @@ -379,6 +379,9 @@ static int sof_compr_pointer(struct
> snd_soc_component *component,
> if (!spcm)
> return -EINVAL;
>
> + if (!sstream->channels || !sstream->sample_container_bytes)
> + return -EBUSY;

Sorry, but why it is BUSY in this case?

> +
> tstamp->sampling_rate = sstream->sampling_rate;
> tstamp->copied_total = sstream->copied_total;
> tstamp->pcm_io_frames = div_u64(spcm->stream[cstream-
> >direction].posn.dai_posn,
>
> ---
> base-commit: c369299895a591d96745d6492d4888259b004a9e
> change-id: 20260326-asoc-compress-tstamp-params-296f38f15217
>
> Best regards,
> --
> Mark Brown <broonie@xxxxxxxxxx>