From patchwork Tue Feb 3 19:39:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 436008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EAC76140161 for ; Wed, 4 Feb 2015 06:45:09 +1100 (AEDT) Received: from localhost ([::1]:32913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIjPI-00029D-89 for incoming@patchwork.ozlabs.org; Tue, 03 Feb 2015 14:45:08 -0500 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 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t13Je3J4031818 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Feb 2015 14:40:03 -0500 Received: from localhost (ovpn-113-107.phx2.redhat.com [10.3.113.107]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t13Je198024716; Tue, 3 Feb 2015 14:40:02 -0500 From: Eduardo Habkost To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gu Zheng , Igor Mammedov , Riku Voipio , Paolo Bonzini Subject: [Qemu-devel] [PATCH v2 6/9] linux-user: Check for cpu_init() errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);