diff mbox

qemu-kvm: x86: fix memleak if ioctl fails

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

Commit Message

Amit Shah July 13, 2009, 8:48 a.m. UTC
Fix a memleak when the KVM_SET_CPUID2 ioctl fails. Free the
memory that we allocate to store cpuids.

Reported-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-kvm-x86.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Marcelo Tosatti July 14, 2009, 10:52 p.m. UTC | #1
On Mon, Jul 13, 2009 at 02:18:50PM +0530, Amit Shah wrote:
> Fix a memleak when the KVM_SET_CPUID2 ioctl fails. Free the
> memory that we allocate to store cpuids.
> 
> Reported-by: Mark McLoughlin <markmc@redhat.com>
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  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;
> -- 
> 1.6.2.5

Applied, thanks.

--
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/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;