]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: compress: Refuse to update timestamps for unconfigured streams
authorMark Brown <broonie@kernel.org>
Wed, 1 Apr 2026 16:57:34 +0000 (17:57 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 2 Apr 2026 09:10:28 +0000 (11:10 +0200)
There are a number of mechanisms, including the userspace accessible
timestamp and buffer availability ioctl()s, which allow us to trigger
a timestamp update on a stream before it has been configured. Since
drivers might rely on stream configuration for reporting of pcm_io_frames,
including potentially doing a division by the number of channels, and
these operations are not meaningful for an unconfigured stream reject
attempts to read timestamps before any configuration is done.

Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260401-alsa-unconfigured-tstamp-v1-1-694c2cb5f71d@kernel.org
sound/core/compress_offload.c

index 5a0308eb4e31dede63ec2f7b0aafde1ed9966e38..db9f516df8422cb6542bea21d063201f3a069fbb 100644 (file)
@@ -185,6 +185,14 @@ static int snd_compr_update_tstamp(struct snd_compr_stream *stream,
 {
        if (!stream->ops->pointer)
                return -ENOTSUPP;
+
+       switch (stream->runtime->state) {
+       case SNDRV_PCM_STATE_OPEN:
+               return -EBADFD;
+       default:
+               break;
+       }
+
        stream->ops->pointer(stream, tstamp);
        pr_debug("dsp consumed till %u total %llu bytes\n", tstamp->byte_offset,
                 tstamp->copied_total);