]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
credit2: avoid NULL deref in csched2_res_pick() when tracing
authorJan Beulich <jbeulich@suse.com>
Tue, 3 Mar 2020 15:01:30 +0000 (16:01 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 3 Mar 2020 15:01:30 +0000 (16:01 +0100)
The issue here results from one of the downsides of using goto: The
early "goto out" and "goto out_up" in the function very clearly bypass
any possible initialization of min_rqd, yet the tracing code at the end
of the function consumes the value. There's even a comment regarding the
trace record not being accurate in this case.

CID: 1460432
Fixes: 9c84bc004653 ("sched: rework credit2 run-queue allocation")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Acked-by: Dario Faggioli <dfaggioli@suse.com>
xen/common/sched/credit2.c

index 8ae3b80d2ec731edac4cab92cab7bdba3f17ed16..c7241944a87294e8ee1deba920c50d2f358953c2 100644 (file)
@@ -2403,7 +2403,7 @@ csched2_res_pick(const struct scheduler *ops, const struct sched_unit *unit)
         } d;
         d.dom = unit->domain->domain_id;
         d.unit = unit->unit_id;
-        d.rq_id = min_rqd->id;
+        d.rq_id = min_rqd ? min_rqd->id : -1;
         d.b_avgload = min_avgload;
         d.new_cpu = new_cpu;
         __trace_var(TRC_CSCHED2_PICKED_CPU, 1,