]> git.proxmox.com Git - qemu.git/commitdiff
cpu: Fix qemu_get_cpu() to return NULL if CPU not found
authorIgor Mammedov <imammedo@redhat.com>
Thu, 7 Mar 2013 18:12:43 +0000 (19:12 +0100)
committerAndreas Färber <afaerber@suse.de>
Tue, 12 Mar 2013 09:35:53 +0000 (10:35 +0100)
Commit 55e5c2850 breaks CPU not found return value, and returns
CPU corresponding to the last non NULL env.
Fix it by returning CPU only if env is not NULL, otherwise CPU is
not found and function should return NULL.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
exec.c

diff --git a/exec.c b/exec.c
index 46a283071a2e908bd9f3aa77af7d2c2694909246..0a96ddbc9344bbaa79e87ed4f33e143a436d59d0 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -260,7 +260,7 @@ CPUState *qemu_get_cpu(int index)
         env = env->next_cpu;
     }
 
-    return cpu;
+    return env ? cpu : NULL;
 }
 
 void cpu_exec_init(CPUArchState *env)