From patchwork Mon Jul 13 08:27:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 35337 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 n6D8S5Cf015205 for ; Mon, 13 Jul 2009 08:28:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754339AbZGMI2D (ORCPT ); Mon, 13 Jul 2009 04:28:03 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752202AbZGMI2C (ORCPT ); Mon, 13 Jul 2009 04:28:02 -0400 Received: from mx2.redhat.com ([66.187.237.31]:47839 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750790AbZGMI2B (ORCPT ); Mon, 13 Jul 2009 04:28:01 -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 n6D8S1pT021395 for ; Mon, 13 Jul 2009 04:28:01 -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 n6D8S0pj012344; Mon, 13 Jul 2009 04:28:00 -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 n6D8Rwkl014546; Mon, 13 Jul 2009 04:27:59 -0400 From: Amit Shah To: avi@redhat.com Cc: kvm@vger.kernel.org, Amit Shah Subject: [PATCH] libkvm: x86: fix memleak if ioctl fails Date: Mon, 13 Jul 2009 13:57:52 +0530 Message-Id: <1247473672-7332-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 for when the KVM_SET_CPUID2 ioctl fails. Free the memory that we allocate to store cpuids. Signed-off-by: Amit Shah --- kvm/libkvm/libkvm-x86.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/kvm/libkvm/libkvm-x86.c b/kvm/libkvm/libkvm-x86.c index 9ca77d5..f1aef76 100644 --- a/kvm/libkvm/libkvm-x86.c +++ b/kvm/libkvm/libkvm-x86.c @@ -499,7 +499,7 @@ int kvm_setup_cpuid2(kvm_context_t kvm, int vcpu, int nent, r = ioctl(kvm->vcpu_fd[vcpu], KVM_SET_CPUID2, cpuid); if (r == -1) { fprintf(stderr, "kvm_setup_cpuid2: %m\n"); - return -errno; + r = -errno; } free(cpuid); return r;