From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH] kvm-all: Use 'tmpcpu' instead of 'cpu' in sub-looping to avoid 'cpu' be NULL Date: Mon, 21 Jul 2014 11:53:06 +0200 Message-ID: <53CCE302.5090904@redhat.com> References: <53C9C82A.2060003@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: qemu-devel@nongnu.org, qemu-trivial@nongnu.org, kvm@vger.kernel.org To: Chen Gang , Michael Tokarev Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51933 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752714AbaGUJxZ (ORCPT ); Mon, 21 Jul 2014 05:53:25 -0400 In-Reply-To: <53C9C82A.2060003@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: Il 19/07/2014 03:21, Chen Gang ha scritto: > 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. > > > Signed-off-by: Chen Gang > --- > kvm-all.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/kvm-all.c b/kvm-all.c > index 3ae30ee..1402f4f 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -2077,12 +2077,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; > } > } > Applying to uq/master, thanks. Paolo