[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] sched: fix sched_move_domain() for domain without vcpus



commit 999e1582f289cfb8d59e2e58927c1cba0ac2ada3
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Wed Sep 15 10:57:47 2021 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Sep 15 10:57:47 2021 +0200

    sched: fix sched_move_domain() for domain without vcpus
    
    In case a domain is created with a cpupool other than Pool-0 specified
    it will be moved to that cpupool before any vcpus are allocated.
    
    This will lead to a NULL pointer dereference in sched_move_domain().
    
    Fix that by tolerating vcpus not being allocated yet.
    
    Fixes: 70fadc41635b9b6 ("xen/cpupool: support moving domain between 
cpupools with different granularity")
    Reported-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Reviewed-by: Dario Faggioli <dfaggioli@xxxxxxxx>
---
 xen/common/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 8d178baf3d..8f4b1ca10d 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -651,7 +651,7 @@ int sched_move_domain(struct domain *d, struct cpupool *c)
     struct scheduler *old_ops = dom_scheduler(d);
     void *old_domdata;
     unsigned int gran = cpupool_get_granularity(c);
-    unsigned int n_units = DIV_ROUND_UP(d->max_vcpus, gran);
+    unsigned int n_units = d->vcpu[0] ? DIV_ROUND_UP(d->max_vcpus, gran) : 0;
     int ret = 0;
 
     for_each_vcpu ( d, v )
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.