target-i386: If x86_cpu_realize() failed, report error and do cleanup

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Igor Mammedov 2012-10-02 17:36:55 +02:00 committed by Andreas Färber
parent 18eb473f89
commit ff287bbdda

View File

@ -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;
}