scheduler: guard against subdivision underflow on domain clear

In some situations the domain clear routine might encounter
a case, when the number of clients is decremented and 0,
as such, a subsequent subdivision will result in an integer underflow.

Signed-off-by: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
This commit is contained in:
Slawomir Blauciak 2021-04-23 17:22:10 +02:00 committed by Liam Girdwood
parent c9f442ba6b
commit b500999477
1 changed files with 5 additions and 3 deletions

View File

@ -331,10 +331,12 @@ static void schedule_ll_domain_clear(struct ll_schedule_data *sch,
if (count == 1) {
sch->domain->registered[cpu_get_id()] = false;
if (atomic_read(&sch->domain->num_clients)) {
count = atomic_sub(&sch->domain->num_clients, 1);
if (count == 1)
domain_clear(sch->domain);
}
}
tr_info(&ll_tr, "num_tasks %d total_num_tasks %d",
atomic_read(&sch->num_tasks),