Skip to content

Commit

Permalink
Fix panic upon cancelling not scheduled task
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
serhiy-katsyuba-intel authored and dbaluta committed Jul 28, 2023
1 parent 6a70f38 commit cff23f5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/schedule/zephyr_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,18 @@ static int zephyr_ll_task_cancel(void *data, struct task *task)
* kept atomic, so we have to lock here too.
*/
zephyr_ll_lock(sch, &flags);
if (task->state != SOF_TASK_STATE_FREE) {

/*
* SOF_TASK_STATE_CANCEL can only be assigned to a task which is on scheduler's list.
* Later such task will be removed from the list by zephyr_ll_task_done(). Do nothing
* for tasks which were never scheduled or were already removed from scheduler's list.
*/
if (task->state != SOF_TASK_STATE_INIT && task->state != SOF_TASK_STATE_FREE) {
task->state = SOF_TASK_STATE_CANCEL;
/* let domain know that a task has been cancelled */
domain_task_cancel(sch->ll_domain, task);
}

zephyr_ll_unlock(sch, &flags);

return 0;
Expand Down

0 comments on commit cff23f5

Please sign in to comment.