From 0ade01edd33181b65393cf3864cb2ac7c5eb1487 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 19 Oct 2026 17:45:33 +0300 Subject: [PATCH] ALSA: compress: reject restarting an ACTIVE task via origin_seqno snd_compr_task_start_prepare() only rejects tasks with state >= SND_COMPRESS_TASK_STATE_FINISHED. Since the enum is IDLE(0) < ACTIVE(1) < FINISHED(2), this accepts ACTIVE tasks and rejects FINISHED ones, the opposite of what the origin_seqno mechanism needs: origin_seqno is meant to let a caller reuse a FINISHED task's buffers for a new job, not to restart a task that is still queued with the driver. The seqno lookup path in snd_compr_task_start() has its own explicit "task->state != IDLE" guard, but the origin_seqno lookup path relies solely on this function, so it can restart an ACTIVE task, causing ops->task_start() to be called twice for the same task and runtime->active_tasks to be incremented twice without a matching finish/stop. Accept IDLE and FINISHED, reject ACTIVE, on both entry paths. Fixes: 04177158cf98 ("ALSA: compress_offload: introduce accel operation mode") Cc: stable@vger.kernel.org Signed-off-by: Peter Ujfalusi Acked-by: Vinod Koul Link: https://patch.msgid.link/20261019144533.30665-5-peter.ujfalusi@linux.intel.com Signed-off-by: Takashi Iwai --- sound/core/compress_offload.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index a250c6b53996..5e5e0f78f26d 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -1206,7 +1206,9 @@ static int snd_compr_task_start_prepare(struct snd_compr_task_runtime *task, { if (task == NULL) return -EINVAL; - if (task->state >= SND_COMPRESS_TASK_STATE_FINISHED) + /* only an unqueued or already finished task may be (re)started */ + if (task->state != SND_COMPRESS_TASK_STATE_IDLE && + task->state != SND_COMPRESS_TASK_STATE_FINISHED) return -EBUSY; if (utask->input_size > task->input->size) return -EINVAL;