From patchwork Sat Jul 19 01:21:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 371765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F335E14018E for ; Sat, 19 Jul 2014 11:22:23 +1000 (EST) Received: from localhost ([::1]:52578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8JLx-00015g-O2 for incoming@patchwork.ozlabs.org; Fri, 18 Jul 2014 21:22:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8JLZ-0000jl-OZ for qemu-devel@nongnu.org; Fri, 18 Jul 2014 21:22:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X8JLQ-0006wv-IK for qemu-devel@nongnu.org; Fri, 18 Jul 2014 21:21:57 -0400 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]:42333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8JLQ-0006wm-AX; Fri, 18 Jul 2014 21:21:48 -0400 Received: by mail-pa0-f41.google.com with SMTP id rd3so5882362pab.14 for ; Fri, 18 Jul 2014 18:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=lcghf/G1OMUC3H0kl+vOb4Wejd7PNkQ6/T4CgajIdqI=; b=YH9d0zfJ2v3AMkGFKOhyBS6TEnGKQf66dg3KshJCDcwJGcwtHtsGYAx+h+oK5cJpHv kie1EcsgNLSwkRP4nzUoYA6hXFYHpiNUdzTeBnIkosHcVv2Tb7IrRHB434CctVgUg5Jr kLo8Pd9a5H5H70+E3f8O6O2Ui+6I4tq7gVk2C09kCuKHOgP2z5QNSk8a3XcGHnJsHc1u EvYLWj9OTY0xZAXC7rO3TQxUuonTplDplnFDevXIdNOYKyYS7pVkG/dRKEGqWEXzxqXH 5K1m981cuBsR1p5h6PFyyVILV+dEub8dZyDTiPT/Ma6wHFyNe+ynUJm6g2VjgkjJLfi7 s/yA== X-Received: by 10.70.94.100 with SMTP id db4mr9402027pdb.122.1405732906544; Fri, 18 Jul 2014 18:21:46 -0700 (PDT) Received: from [192.168.1.101] ([223.72.65.45]) by mx.google.com with ESMTPSA id gu4sm6839899pbb.54.2014.07.18.18.21.44 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 18 Jul 2014 18:21:45 -0700 (PDT) Message-ID: <53C9C82A.2060003@gmail.com> Date: Sat, 19 Jul 2014 09:21:46 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Michael Tokarev , pbonzini@redhat.com X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::229 Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH] kvm-all: Use 'tmpcpu' instead of 'cpu' in sub-looping to avoid 'cpu' be NULL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; } }