diff --git a/xen/common/sched/null.c b/xen/common/sched/null.c index 65a0a6c531..2091337fcd 100644 --- a/xen/common/sched/null.c +++ b/xen/common/sched/null.c @@ -522,6 +522,8 @@ static void cf_check null_unit_remove( { struct null_private *prv = null_priv(ops); struct null_unit *nvc = null_unit(unit); + struct null_pcpu *npc; + unsigned int cpu; spinlock_t *lock; ASSERT(!is_idle_unit(unit)); @@ -531,8 +533,6 @@ static void cf_check null_unit_remove( /* If offline, the unit shouldn't be assigned, nor in the waitqueue */ if ( unlikely(!is_unit_online(unit)) ) { - struct null_pcpu *npc; - npc = unit->res->sched_priv; ASSERT(npc->unit != unit); ASSERT(list_empty(&nvc->waitq_elem)); @@ -549,7 +549,10 @@ static void cf_check null_unit_remove( goto out; } - unit_deassign(prv, unit); + cpu = sched_unit_master(unit); + npc = get_sched_res(cpu)->sched_priv; + if ( npc->unit ) + unit_deassign(prv, unit); out: unit_schedule_unlock_irq(lock, unit);