Skip to content

Commit cff23f5

Browse files
serhiy-katsyuba-inteldbaluta
authored andcommitted
Fix panic upon cancelling not scheduled task
Calling zephyr_ll_task_cancel() for a task which was actually never scheduled results later in panic in zephyr_ll_task_done(). The fix makes zephyr_ll_task_cancel() do nothing for tasks which were only initialized but never scheduled. Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
1 parent 6a70f38 commit cff23f5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/schedule/zephyr_ll.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,18 @@ static int zephyr_ll_task_cancel(void *data, struct task *task)
436436
* kept atomic, so we have to lock here too.
437437
*/
438438
zephyr_ll_lock(sch, &flags);
439-
if (task->state != SOF_TASK_STATE_FREE) {
439+
440+
/*
441+
* SOF_TASK_STATE_CANCEL can only be assigned to a task which is on scheduler's list.
442+
* Later such task will be removed from the list by zephyr_ll_task_done(). Do nothing
443+
* for tasks which were never scheduled or were already removed from scheduler's list.
444+
*/
445+
if (task->state != SOF_TASK_STATE_INIT && task->state != SOF_TASK_STATE_FREE) {
440446
task->state = SOF_TASK_STATE_CANCEL;
441447
/* let domain know that a task has been cancelled */
442448
domain_task_cancel(sch->ll_domain, task);
443449
}
450+
444451
zephyr_ll_unlock(sch, &flags);
445452

446453
return 0;

0 commit comments

Comments
 (0)