[RFC,07/13] cpu_x86_create: move error handling to end of function

Submitted by Eduardo Habkost on Aug. 16, 2012, 4:59 p.m.

Details

Message ID 1345136352-10756-8-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Aug. 16, 2012, 4:59 p.m.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/cpu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index da7b5af..0bf62da 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1544,12 +1544,14 @@  X86CPU *cpu_x86_create(const char *cpu_model)
     env->cpu_model_str = cpu_model;
 
     if (cpu_x86_register(cpu, cpu_model) < 0) {
-        object_delete(OBJECT(cpu));
-        return NULL;
+        goto error;
     }
 
     x86_cpu_realize(OBJECT(cpu), NULL);
     return cpu;
+error:
+    object_delete(OBJECT(cpu));
+    return NULL;
 }
 
 #if !defined(CONFIG_USER_ONLY)