]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
linux-user: Check for cpu_init() errors
authorEduardo Habkost <ehabkost@redhat.com>
Tue, 3 Feb 2015 18:48:51 +0000 (16:48 -0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 9 Mar 2015 03:58:13 +0000 (22:58 -0500)
This was the only caller of cpu_init() that was not checking for NULL
yet.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
(cherry picked from commit 696da41b1b741f6056e52c572e05abd790637be1)

Conflicts:
linux-user/main.c

*removed context dependency on ec53b45

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
linux-user/main.c

index 5c14c1e874a23a07c10cc87c114985c9c84be153..f2cf2b6f0534b70762a4e5df462ae06f8d38427c 100644 (file)
@@ -3435,12 +3435,19 @@ CPUArchState *cpu_copy(CPUArchState *env)
 {
     CPUState *cpu = ENV_GET_CPU(env);
     CPUArchState *new_env = cpu_init(cpu_model);
-    CPUState *new_cpu = ENV_GET_CPU(new_env);
+    CPUState *new_cpu;
 #if defined(TARGET_HAS_ICE)
     CPUBreakpoint *bp;
     CPUWatchpoint *wp;
 #endif
 
+    if (!new_env) {
+        fprintf(stderr, "cpu_copy: Failed to create new CPU\n");
+        exit(1);
+    }
+
+    new_cpu = ENV_GET_CPU(new_env);
+
     /* Reset non arch specific state */
     cpu_reset(new_cpu);