In case cpu_schedule_up() is failing to allocate memory for struct
sched_resource, cpu_schedule_down() will be called with the
sched_resource pointer being NULL. This needs to be handled.

Reported-by: Jan Beulich <[email protected]>
Fixes: 207589dbacd4 ("xen/sched: move per cpu scheduler private data into 
struct sched_resource")
Signed-off-by: Juergen Gross <[email protected]>
---
 xen/common/sched/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index d84b65f197..0dc86b8f6c 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -2829,6 +2829,8 @@ static void cpu_schedule_down(unsigned int cpu)
     rcu_read_lock(&sched_res_rculock);
 
     sr = get_sched_res(cpu);
+    if ( !sr )
+        goto out;
 
     kill_timer(&sr->s_timer);
 
@@ -2839,6 +2841,7 @@ static void cpu_schedule_down(unsigned int cpu)
     sr->sched_unit_idle = NULL;
     call_rcu(&sr->rcu, sched_res_free);
 
+ out:
     rcu_read_unlock(&sched_res_rculock);
 }
 
-- 
2.35.3


Reply via email to