diff mbox

[01/17] cpu: Fix qemu_get_cpu() to return NULL if CPU not found

Message ID 1363081758-12913-2-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber March 12, 2013, 9:49 a.m. UTC
From: Igor Mammedov <imammedo@redhat.com>

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 |    2 +-
 1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-)
diff mbox

Patch

diff --git a/exec.c b/exec.c
index 46a2830..0a96ddb 100644
--- 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)