From: Chen Gang Date: Sat, 19 Jul 2014 01:21:46 +0000 (+0800) Subject: kvm-all: Use 'tmpcpu' instead of 'cpu' in sub-looping to avoid 'cpu' be NULL X-Git-Tag: qemu-xen-4.5.0-rc1^2~14 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=046e3573799e4d09f34353cd5a3bce2c597d5c3c;p=qemu-upstream-4.5-testing.git kvm-all: Use 'tmpcpu' instead of 'cpu' in sub-looping to avoid 'cpu' be NULL If kvm_arch_remove_sw_breakpoint() in CPU_FOREACH() always be fail, it will let 'cpu' NULL. And the next kvm_arch_remove_sw_breakpoint() in QTAILQ_FOREACH_SAFE() will get NULL parameter for 'cpu'. And kvm_arch_remove_sw_breakpoint() can assumes 'cpu' must never be NULL, so need define additional temporary variable for 'cpu' to avoid the case. Cc: qemu-stable@nongnu.org Signed-off-by: Chen Gang Signed-off-by: Paolo Bonzini (cherry picked from commit dc54e2525389e903cee2b847cf761b5d857f75cb) Signed-off-by: Michael Roth --- diff --git a/kvm-all.c b/kvm-all.c index cd614965e..2754c1522 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -2022,12 +2022,13 @@ void kvm_remove_all_breakpoints(CPUState *cpu) { struct kvm_sw_breakpoint *bp, *next; KVMState *s = cpu->kvm_state; + CPUState *tmpcpu; QTAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) { if (kvm_arch_remove_sw_breakpoint(cpu, bp) != 0) { /* Try harder to find a CPU that currently sees the breakpoint. */ - CPU_FOREACH(cpu) { - if (kvm_arch_remove_sw_breakpoint(cpu, bp) == 0) { + CPU_FOREACH(tmpcpu) { + if (kvm_arch_remove_sw_breakpoint(tmpcpu, bp) == 0) { break; } }