[PATCH] libkvm: x86: fix memleak if ioctl fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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;
-- 
1.6.2.5

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

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux