diff mbox

libkvm: x86: fix memleak if ioctl fails

Message ID 1247473672-7332-1-git-send-email-amit.shah@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Amit Shah July 13, 2009, 8:27 a.m. UTC
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 <amit.shah@redhat.com>
---
 kvm/libkvm/libkvm-x86.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Avi Kivity July 13, 2009, 8:38 a.m. UTC | #1
On 07/13/2009 11:27 AM, Amit Shah wrote:
> Fix a memleak for when the KVM_SET_CPUID2 ioctl fails. Free the
> memory that we allocate to store cpuids.
>
>    

Applied, thanks.  Note that this libkvm is practically unused (the test 
suite uses it but I want to move that to qemu -kernel).
Amit Shah July 13, 2009, 8:41 a.m. UTC | #2
On (Mon) Jul 13 2009 [11:38:18], Avi Kivity wrote:
> On 07/13/2009 11:27 AM, Amit Shah wrote:
>> Fix a memleak for when the KVM_SET_CPUID2 ioctl fails. Free the
>> memory that we allocate to store cpuids.
>>
>>    
>
> Applied, thanks.  Note that this libkvm is practically unused (the test  
> suite uses it but I want to move that to qemu -kernel).

I'll prepare a patch for qemu-kvm-x86.c.

		Amit
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;