From patchwork Tue Jun 10 16:08:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 358074 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 67B6E1400B8 for ; Wed, 11 Jun 2014 03:30:05 +1000 (EST) Received: from localhost ([::1]:41496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuPs3-0003jX-20 for incoming@patchwork.ozlabs.org; Tue, 10 Jun 2014 13:30:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuPq6-0008U0-6r for qemu-devel@nongnu.org; Tue, 10 Jun 2014 13:28:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuPpz-0000SB-BP for qemu-devel@nongnu.org; Tue, 10 Jun 2014 13:28:02 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:45475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuPpy-0000Rh-Pm; Tue, 10 Jun 2014 13:27:54 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 98687412D9; Tue, 10 Jun 2014 21:27:53 +0400 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id 8D3F36DF; Tue, 10 Jun 2014 20:08:51 +0400 (MSK) Received: (nullmailer pid 13332 invoked by uid 1000); Tue, 10 Jun 2014 16:08:47 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Tue, 10 Jun 2014 20:08:38 +0400 Message-Id: <1402416523-13212-21-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1402416523-13212-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1402416523-13212-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Paolo Bonzini , Michael Tokarev Subject: [Qemu-devel] [PULL 20/25] cpu/x86: correctly set errors in x86_cpu_parse_featurestr 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 From: Paolo Bonzini Because of the "goto out", the contents of local_err are leaked and lost. Signed-off-by: Paolo Bonzini Signed-off-by: Michael Tokarev --- target-i386/cpu.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index dde052c..8983457 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1688,8 +1688,8 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, numvalue = strtoul(val, &err, 0); if (!*val || *err) { - error_setg(&local_err, "bad numerical value %s", val); - goto out; + error_setg(errp, "bad numerical value %s", val); + return; } if (numvalue < 0x80000000) { error_report("xlevel value shall always be >= 0x80000000" @@ -1706,8 +1706,8 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, tsc_freq = strtosz_suffix_unit(val, &err, STRTOSZ_DEFSUFFIX_B, 1000); if (tsc_freq < 0 || *err) { - error_setg(&local_err, "bad numerical value %s", val); - goto out; + error_setg(errp, "bad numerical value %s", val); + return; } snprintf(num, sizeof(num), "%" PRId64, tsc_freq); object_property_parse(OBJECT(cpu), num, "tsc-frequency", @@ -1718,8 +1718,8 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, char num[32]; numvalue = strtoul(val, &err, 0); if (!*val || *err) { - error_setg(&local_err, "bad numerical value %s", val); - goto out; + error_setg(errp, "bad numerical value %s", val); + return; } if (numvalue < min) { error_report("hv-spinlocks value shall always be >= 0x%x" @@ -1738,7 +1738,7 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, } if (local_err) { error_propagate(errp, local_err); - goto out; + return; } featurestr = strtok(NULL, ","); } @@ -1758,9 +1758,6 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, env->features[FEAT_KVM] &= ~minus_features[FEAT_KVM]; env->features[FEAT_SVM] &= ~minus_features[FEAT_SVM]; env->features[FEAT_7_0_EBX] &= ~minus_features[FEAT_7_0_EBX]; - -out: - return; } /* generate a composite string into buf of all cpuid names in featureset