KVM: x86: Fix leak of free lapic date in kvm_arch_vcpu_init()
authorWei Yongjun <yjwei@cn.fujitsu.com>
Fri, 22 Jan 2010 06:21:29 +0000 (14:21 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 28 Jan 2010 23:02:48 +0000 (15:02 -0800)
commit 443c39bc9ef7d8f648408d74c97e943f3bb3f48a upstream.

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>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/x86.c

index 1bd161ed168a70e185e2eff03b001ac41b135425..6378e07426919d2e87b3bf79a0be344b18d72694 100644 (file)
@@ -4766,12 +4766,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: