* [PATCH 1/2] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks
@ 2010-01-22 6:18 Wei Yongjun
2010-01-22 6:21 ` [PATCH 2/2] KVM: x86: Fix leak of free lapic date in kvm_arch_vcpu_init() Wei Yongjun
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wei Yongjun @ 2010-01-22 6:18 UTC (permalink / raw)
To: kvm, Avi Kivity
vcpu->arch.mce_banks is malloc in kvm_arch_vcpu_init(), but
never free in any place, this may cause memory leak. So this
patch fixed to free it in kvm_arch_vcpu_uninit().
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
arch/x86/kvm/x86.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f25b52e..1ddcad4 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5089,6 +5089,7 @@ fail:
void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
{
+ kfree(vcpu->arch.mce_banks);
kvm_free_lapic(vcpu);
down_read(&vcpu->kvm->slots_lock);
kvm_mmu_destroy(vcpu);
--
1.6.2.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] KVM: x86: Fix leak of free lapic date in kvm_arch_vcpu_init()
2010-01-22 6:18 [PATCH 1/2] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks Wei Yongjun
@ 2010-01-22 6:21 ` Wei Yongjun
2010-01-22 6:41 ` [PATCH 1/2 v2] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks Wei Yongjun
2010-01-22 8:55 ` [PATCH] KVM: MMU: Remove some useless code from alloc_mmu_pages() Wei Yongjun
2 siblings, 0 replies; 5+ messages in thread
From: Wei Yongjun @ 2010-01-22 6:21 UTC (permalink / raw)
To: kvm, Avi Kivity
In function kvm_arch_vcpu_init(), if the memory malloc for
vcpu->arch.mce_banks is fail, it does not free the memory
of lapic date. This patch fixed it.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
arch/x86/kvm/x86.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6651dbf..f25b52e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5072,12 +5072,13 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
GFP_KERNEL);
if (!vcpu->arch.mce_banks) {
r = -ENOMEM;
- goto fail_mmu_destroy;
+ goto fail_free_lapic;
}
vcpu->arch.mcg_cap = KVM_MAX_MCE_BANKS;
return 0;
-
+fail_free_lapic:
+ kvm_free_lapic(vcpu);
fail_mmu_destroy:
kvm_mmu_destroy(vcpu);
fail_free_pio_data:
--
1.6.2.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 1/2 v2] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks
2010-01-22 6:18 [PATCH 1/2] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks Wei Yongjun
2010-01-22 6:21 ` [PATCH 2/2] KVM: x86: Fix leak of free lapic date in kvm_arch_vcpu_init() Wei Yongjun
@ 2010-01-22 6:41 ` Wei Yongjun
2010-01-22 8:55 ` [PATCH] KVM: MMU: Remove some useless code from alloc_mmu_pages() Wei Yongjun
2 siblings, 0 replies; 5+ messages in thread
From: Wei Yongjun @ 2010-01-22 6:41 UTC (permalink / raw)
To: kvm, Avi Kivity
vcpu->arch.mce_banks is malloc in kvm_arch_vcpu_init(), but
never free in any place, this may cause memory leak. So this
patch fixed to free it in kvm_arch_vcpu_uninit().
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
arch/x86/kvm/x86.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 56a90a6..c27ebb1 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5470,6 +5470,7 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
{
int idx;
+ kfree(vcpu->arch.mce_banks);
kvm_free_lapic(vcpu);
idx = srcu_read_lock(&vcpu->kvm->srcu);
kvm_mmu_destroy(vcpu);
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH] KVM: MMU: Remove some useless code from alloc_mmu_pages()
2010-01-22 6:18 [PATCH 1/2] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks Wei Yongjun
2010-01-22 6:21 ` [PATCH 2/2] KVM: x86: Fix leak of free lapic date in kvm_arch_vcpu_init() Wei Yongjun
2010-01-22 6:41 ` [PATCH 1/2 v2] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks Wei Yongjun
@ 2010-01-22 8:55 ` Wei Yongjun
2010-01-23 19:23 ` Marcelo Tosatti
2 siblings, 1 reply; 5+ messages in thread
From: Wei Yongjun @ 2010-01-22 8:55 UTC (permalink / raw)
To: kvm, Avi Kivity
If we fail to alloc page for vcpu->arch.mmu.pae_root, call to
free_mmu_pages() is unnecessary, which just do free the page
malloc for vcpu->arch.mmu.pae_root.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
arch/x86/kvm/mmu.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 4c3e5b2..5d8e01b 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2849,16 +2849,13 @@ static int alloc_mmu_pages(struct kvm_vcpu *vcpu)
*/
page = alloc_page(GFP_KERNEL | __GFP_DMA32);
if (!page)
- goto error_1;
+ return -ENOMEM;
+
vcpu->arch.mmu.pae_root = page_address(page);
for (i = 0; i < 4; ++i)
vcpu->arch.mmu.pae_root[i] = INVALID_PAGE;
return 0;
-
-error_1:
- free_mmu_pages(vcpu);
- return -ENOMEM;
}
int kvm_mmu_create(struct kvm_vcpu *vcpu)
--
1.6.2.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-01-23 19:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-22 6:18 [PATCH 1/2] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks Wei Yongjun
2010-01-22 6:21 ` [PATCH 2/2] KVM: x86: Fix leak of free lapic date in kvm_arch_vcpu_init() Wei Yongjun
2010-01-22 6:41 ` [PATCH 1/2 v2] KVM: x86: Fix probable memory leak of vcpu->arch.mce_banks Wei Yongjun
2010-01-22 8:55 ` [PATCH] KVM: MMU: Remove some useless code from alloc_mmu_pages() Wei Yongjun
2010-01-23 19:23 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox