From: Eduardo Habkost Date: Tue, 3 Feb 2015 18:48:51 +0000 (-0200) Subject: linux-user: Check for cpu_init() errors X-Git-Tag: qemu-xen-4.6.0-rc1~34^2~7 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a958b9be8697dd2316669a83e85c68ccd85bfc49;p=qemu-upstream-unstable.git linux-user: Check for cpu_init() errors This was the only caller of cpu_init() that was not checking for NULL yet. Reviewed-by: Paolo Bonzini Signed-off-by: Eduardo Habkost (cherry picked from commit 696da41b1b741f6056e52c572e05abd790637be1) Conflicts: linux-user/main.c *removed context dependency on ec53b45 Signed-off-by: Michael Roth --- diff --git a/linux-user/main.c b/linux-user/main.c index 5c14c1e87..f2cf2b6f0 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3435,12 +3435,19 @@ 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; #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp; CPUWatchpoint *wp; #endif + 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);