diff mbox

[v2,6/9] linux-user: Check for cpu_init() errors

Message ID 1422992371-4145-7-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Feb. 3, 2015, 7:39 p.m. UTC
This was the only caller of cpu_init() that was not checking for NULL
yet.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
---
 linux-user/main.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/linux-user/main.c b/linux-user/main.c
index cfa7d07..d0ecde4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -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);