From patchwork Tue Dec 18 16:30:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 207154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 27E1F2C007E for ; Wed, 19 Dec 2012 03:31:14 +1100 (EST) Received: from localhost ([::1]:44081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl04W-0000QH-Bw for incoming@patchwork.ozlabs.org; Tue, 18 Dec 2012 11:31:12 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl04O-0000Q8-RR for qemu-devel@nongnu.org; Tue, 18 Dec 2012 11:31:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tl04K-0007CH-3S for qemu-devel@nongnu.org; Tue, 18 Dec 2012 11:31:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl04J-0007CB-RA for qemu-devel@nongnu.org; Tue, 18 Dec 2012 11:31:00 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBIGUxam001262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Dec 2012 11:30:59 -0500 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBIGUqFW021669; Tue, 18 Dec 2012 11:30:58 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Tue, 18 Dec 2012 17:30:43 +0100 Message-Id: <1355848243-25704-1-git-send-email-imammedo@redhat.com> In-Reply-To: <1355760092-18755-8-git-send-email-imammedo@redhat.com> References: <1355760092-18755-8-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: ehabkost@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 07/20 v2] target-i386: cpu_x86_register() consolidate freeing resources 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 freeing resources in one place would require setting 'error' to not NULL, so add some more error reporting before jumping to exit branch. Signed-off-by: Igor Mammedov --- v2: - add missing 'return -1' on exit if error is not NULL, Spotted-By: Eduardo Habkost --- target-i386/cpu.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 3b9bbfe..fe8b76c 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1550,13 +1550,14 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model) model_pieces = g_strsplit(cpu_model, ",", 2); if (!model_pieces[0]) { - goto error; + goto out; } name = model_pieces[0]; features = model_pieces[1]; if (cpu_x86_find_by_name(def, name) < 0) { - goto error; + error_setg(&error, "Unable to find CPU definition: %s", name); + goto out; } def->kvm_features |= kvm_default_features; @@ -1566,22 +1567,20 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model) &def->svm_features, &def->cpuid_7_0_ebx_features); if (cpu_x86_parse_featurestr(def, features) < 0) { - goto error; + error_setg(&error, "Invalid cpu_model string format: %s", cpu_model); + goto out; } cpudef_2_x86_cpu(cpu, def, &error); +out: + g_strfreev(model_pieces); if (error) { fprintf(stderr, "%s\n", error_get_pretty(error)); error_free(error); - goto error; + return -1; } - - g_strfreev(model_pieces); return 0; -error: - g_strfreev(model_pieces); - return -1; } #if !defined(CONFIG_USER_ONLY)