From: Andrew Cooper Date: Wed, 28 Feb 2018 11:43:25 +0000 (+0000) Subject: xen/domain: Call sched_destroy_domain() in the domain_create() error path X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~448 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c77ec3478ac0e117c814789bdd4caab60b4732c5;p=xen.git xen/domain: Call sched_destroy_domain() in the domain_create() error path If domain_create() fails, complete_domain_destroy() doesn't get called, meaning that sched_destroy_domain() is missed. In practice, this can only fail because of exceptional late_hwdom_init() issues at the moment. Make sched_destroy_domain() idempotent, and call it in the fail path. Signed-off-by: Andrew Cooper Reviewed-by: George Dunlap Reviewed-by: Dario Faggioli --- diff --git a/xen/common/domain.c b/xen/common/domain.c index e0b024cca4..3cefe765a2 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -404,6 +404,9 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags, hardware_domain = old_hwdom; atomic_set(&d->refcnt, DOMAIN_DESTROYED); xfree(d->pbuf); + + sched_destroy_domain(d); + if ( init_status & INIT_arch ) arch_domain_destroy(d); if ( init_status & INIT_gnttab ) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 5f596f0ec6..64524f4da7 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -436,16 +436,18 @@ int sched_init_domain(struct domain *d, int poolid) void sched_destroy_domain(struct domain *d) { - ASSERT(d->cpupool != NULL || is_idle_domain(d)); ASSERT(d->domain_id < DOMID_FIRST_RESERVED); - SCHED_STAT_CRANK(dom_destroy); - TRACE_1D(TRC_SCHED_DOM_REM, d->domain_id); + if ( d->cpupool ) + { + SCHED_STAT_CRANK(dom_destroy); + TRACE_1D(TRC_SCHED_DOM_REM, d->domain_id); - sched_free_domdata(dom_scheduler(d), d->sched_priv); - d->sched_priv = NULL; + sched_free_domdata(dom_scheduler(d), d->sched_priv); + d->sched_priv = NULL; - cpupool_rm_domain(d); + cpupool_rm_domain(d); + } } void vcpu_sleep_nosync(struct vcpu *v)