From 82af7d22a69a8cac633a6b2a40bc7d52dac5c5e8 Mon Sep 17 00:00:00 2001 From: Juergen Gross To: xen-devel@xxxxxxxxxxxxxxxxxxxx Cc: George Dunlap Cc: Dario Faggioli Date: Mon, 6 Sep 2021 11:19:12 +0200 Subject: [PATCH] xen/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: 61649709421a5a7c1 ("xen/domain: Allocate d->vcpu[] in domain_create()") Reported-by: Bertrand Marquis Signed-off-by: Juergen Gross --- xen/common/sched/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 8d178baf3d..79c9100680 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -671,6 +671,10 @@ int sched_move_domain(struct domain *d, struct cpupool *c) for ( unit_idx = 0; unit_idx < n_units; unit_idx++ ) { + /* Special case for move at domain creation time. */ + if ( !d->vcpu[unit_idx * gran] ) + break; + unit = sched_alloc_unit_mem(); if ( unit ) { -- 2.26.2