Received: from eggs.gnu.org ([2001:4830:134:3::10]:46995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIjKb-0003c2-2b for qemu-devel@nongnu.org; Tue, 03 Feb 2015 14:40:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIjKZ-0007Fo-Uh for qemu-devel@nongnu.org; Tue, 03 Feb 2015 14:40:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:10997) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIjKZ-0007Fi-Ob for qemu-devel@nongnu.org; Tue, 03 Feb 2015 14:40:15 -0500 From: Eduardo Habkost Date: Tue, 3 Feb 2015 17:39:28 -0200 Message-Id: <1422992371-4145-7-git-send-email-ehabkost@redhat.com> In-Reply-To: <1422992371-4145-1-git-send-email-ehabkost@redhat.com> References: <1422992371-4145-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH v2 6/9] linux-user: Check for cpu_init() errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gu Zheng , Igor Mammedov , Riku Voipio , Paolo Bonzini This was the only caller of cpu_init() that was not checking for NULL yet. Signed-off-by: Eduardo Habkost Cc: Riku Voipio --- linux-user/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); -- 2.1.0