Patchwork [02/35] target-i386: If x86_cpu_realize() failed, report error and do cleanup

login
register
mail settings
Submitter Andreas Färber
Date Oct. 31, 2012, 12:59 a.m.
Message ID <1351645206-3041-3-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/195673/
State New
Headers show

Comments

Andreas Färber - Oct. 31, 2012, 12:59 a.m.
From: Igor Mammedov <imammedo@redhat.com>

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-i386/helper.c |    9 +++++++--
 1 Datei geändert, 7 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

Patch

diff --git a/target-i386/helper.c b/target-i386/helper.c
index c5d42c5..0424ccf 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1243,6 +1243,7 @@  X86CPU *cpu_x86_init(const char *cpu_model)
 {
     X86CPU *cpu;
     CPUX86State *env;
+    Error *error = NULL;
 
     cpu = X86_CPU(object_new(TYPE_X86_CPU));
     env = &cpu->env;
@@ -1253,8 +1254,12 @@  X86CPU *cpu_x86_init(const char *cpu_model)
         return NULL;
     }
 
-    x86_cpu_realize(OBJECT(cpu), NULL);
-
+    x86_cpu_realize(OBJECT(cpu), &error);
+    if (error) {
+        error_free(error);
+        object_delete(OBJECT(cpu));
+        return NULL;
+    }
     return cpu;
 }