Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 443c39bc authored by Wei Yongjun's avatar Wei Yongjun Committed by Marcelo Tosatti
Browse files

KVM: x86: Fix leak of free lapic date in kvm_arch_vcpu_init()



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.

Cc: stable@kernel.org
Signed-off-by: default avatarWei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 36cb93fd
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -5072,12 +5072,13 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
				       GFP_KERNEL);
				       GFP_KERNEL);
	if (!vcpu->arch.mce_banks) {
	if (!vcpu->arch.mce_banks) {
		r = -ENOMEM;
		r = -ENOMEM;
		goto fail_mmu_destroy;
		goto fail_free_lapic;
	}
	}
	vcpu->arch.mcg_cap = KVM_MAX_MCE_BANKS;
	vcpu->arch.mcg_cap = KVM_MAX_MCE_BANKS;


	return 0;
	return 0;

fail_free_lapic:
	kvm_free_lapic(vcpu);
fail_mmu_destroy:
fail_mmu_destroy:
	kvm_mmu_destroy(vcpu);
	kvm_mmu_destroy(vcpu);
fail_free_pio_data:
fail_free_pio_data: