]> xenbits.xensource.com Git - qemu-xen.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)
committerEduardo Habkost <ehabkost@redhat.com>
Wed, 25 Feb 2015 18:00:07 +0000 (15:00 -0300)
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>
linux-user/main.c

index d92702a7348ccf461d922b48974d38f38e547a0b..111c1ffafcfaadec39e1a466bf2b7c6d0d7f7257 100644 (file)
@@ -3453,10 +3453,17 @@ 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;
     CPUBreakpoint *bp;
     CPUWatchpoint *wp;
 
+    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);