From: Marcelo Tosatti <mtosatti@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 10/10] Fix memory leak in register save load due to xsave support
Date: Wed, 20 Oct 2010 15:43:47 -0200 [thread overview]
Message-ID: <13cda55bbbd7b8111b845b09b97d184a6e2477a8.1287596626.git.mtosatti@redhat.com> (raw)
In-Reply-To: <cover.1287596626.git.mtosatti@redhat.com>
From: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
target-i386/kvm.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 1701cb9..2449c2f 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -660,7 +660,7 @@ static int kvm_put_fpu(CPUState *env)
static int kvm_put_xsave(CPUState *env)
{
#ifdef KVM_CAP_XSAVE
- int i;
+ int i, r;
struct kvm_xsave* xsave;
uint16_t cwd, swd, twd, fop;
@@ -685,7 +685,9 @@ static int kvm_put_xsave(CPUState *env)
*(uint64_t *)&xsave->region[XSAVE_XSTATE_BV] = env->xstate_bv;
memcpy(&xsave->region[XSAVE_YMMH_SPACE], env->ymmh_regs,
sizeof env->ymmh_regs);
- return kvm_vcpu_ioctl(env, KVM_SET_XSAVE, xsave);
+ r = kvm_vcpu_ioctl(env, KVM_SET_XSAVE, xsave);
+ qemu_free(xsave);
+ return r;
#else
return kvm_put_fpu(env);
#endif
@@ -850,8 +852,10 @@ static int kvm_get_xsave(CPUState *env)
xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));
ret = kvm_vcpu_ioctl(env, KVM_GET_XSAVE, xsave);
- if (ret < 0)
+ if (ret < 0) {
+ qemu_free(xsave);
return ret;
+ }
cwd = (uint16_t)xsave->region[0];
swd = (uint16_t)(xsave->region[0] >> 16);
@@ -870,6 +874,7 @@ static int kvm_get_xsave(CPUState *env)
env->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV];
memcpy(env->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE],
sizeof env->ymmh_regs);
+ qemu_free(xsave);
return 0;
#else
return kvm_get_fpu(env);
--
1.7.2.1
next prev parent reply other threads:[~2010-10-20 17:45 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-20 17:43 [Qemu-devel] [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 01/10] Set cpuid definition to 0 before initializing it Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 02/10] Add svm cpuid features Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 03/10] signalfd compatibility Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 04/10] iothread: use signalfd Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 05/10] kvm: x86: add mce support Marcelo Tosatti
2010-10-20 19:58 ` [Qemu-devel] " Anthony Liguori
2010-10-20 17:43 ` [Qemu-devel] [PATCH 06/10] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 07/10] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-20 19:56 ` [Qemu-devel] " Anthony Liguori
2010-10-20 17:43 ` [Qemu-devel] [PATCH 08/10] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-20 19:51 ` [Qemu-devel] " Anthony Liguori
2010-10-20 20:59 ` Anthony Liguori
2010-10-20 21:33 ` Marcelo Tosatti
2010-10-20 21:28 ` Marcelo Tosatti
2010-10-20 21:56 ` Paolo Bonzini
2010-10-20 22:03 ` Anthony Liguori
2010-10-21 7:41 ` Paolo Bonzini
2010-10-20 17:43 ` [Qemu-devel] [PATCH 09/10] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-20 19:54 ` [Qemu-devel] " Anthony Liguori
2010-10-20 17:43 ` Marcelo Tosatti [this message]
2010-10-20 19:01 ` [Qemu-devel] Re: [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Anthony Liguori
2010-10-20 19:05 ` Marcelo Tosatti
2010-10-20 19:15 ` Anthony Liguori
2010-10-20 19:52 ` Anthony Liguori
2010-10-20 21:59 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13cda55bbbd7b8111b845b09b97d184a6e2477a8.1287596626.git.mtosatti@redhat.com \
--to=mtosatti@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).