From patchwork Mon Jul 13 08:48:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 35339 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6D8n1uU017873 for ; Mon, 13 Jul 2009 08:49:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754723AbZGMItA (ORCPT ); Mon, 13 Jul 2009 04:49:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754706AbZGMItA (ORCPT ); Mon, 13 Jul 2009 04:49:00 -0400 Received: from mx2.redhat.com ([66.187.237.31]:43131 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754702AbZGMIs7 (ORCPT ); Mon, 13 Jul 2009 04:48:59 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6D8mxIb025977 for ; Mon, 13 Jul 2009 04:48:59 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6D8mwbt016714; Mon, 13 Jul 2009 04:48:58 -0400 Received: from localhost (vpn-12-134.rdu.redhat.com [10.11.12.134]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6D8muNh018196; Mon, 13 Jul 2009 04:48:57 -0400 From: Amit Shah To: avi@redhat.com Cc: kvm@vger.kernel.org, Amit Shah Subject: [PATCH] qemu-kvm: x86: fix memleak if ioctl fails Date: Mon, 13 Jul 2009 14:18:50 +0530 Message-Id: <1247474930-7905-1-git-send-email-amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Fix a memleak when the KVM_SET_CPUID2 ioctl fails. Free the memory that we allocate to store cpuids. Reported-by: Mark McLoughlin Signed-off-by: Amit Shah --- qemu-kvm-x86.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index daf60b6..ede9add 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -551,7 +551,7 @@ int kvm_setup_cpuid2(kvm_vcpu_context_t vcpu, int nent, r = ioctl(vcpu->fd, KVM_SET_CPUID2, cpuid); if (r == -1) { fprintf(stderr, "kvm_setup_cpuid2: %m\n"); - return -errno; + r = -errno; } free(cpuid); return r;