From: Andrew Cooper Date: Wed, 28 Feb 2018 14:02:41 +0000 (+0000) Subject: xen/domain: Added debug safety in the domain_create() failure path X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~444 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ca8c67629a509f45e83ebdb0f679b692707ad7d9;p=xen.git xen/domain: Added debug safety in the domain_create() failure path Hitting the fail path with err = 0 causes callers to dereference a NULL pointer, as 0 fails an IS_ERR() check. All of the paths appear to be fine, but leave some logic to help catch stray misuses. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- diff --git a/xen/common/domain.c b/xen/common/domain.c index 3cefe765a2..219a3e325e 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -399,6 +399,9 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags, return d; fail: + ASSERT(err < 0); /* Sanity check paths leading here. */ + err = err ?: -EILSEQ; /* Release build safety. */ + d->is_dying = DOMDYING_dead; if ( hardware_domain == d ) hardware_domain = old_hwdom;