]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: fix memoryleak in kvm_arch_vcpu_create()
authorMiaohe Lin <linmiaohe@huawei.com>
Thu, 1 Sep 2022 12:23:00 +0000 (20:23 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 1 Sep 2022 23:20:58 +0000 (19:20 -0400)
commitedeefb6ba43eade7837eda77193980fd947b15cc
treeffbb93f0555d91145fbf3c842218aba393cdf24d
parent306e89fa6d2b192e3c4e5e699f4e5529fa9fee2d
KVM: x86: fix memoryleak in kvm_arch_vcpu_create()

When allocating memory for mci_ctl2_banks fails, KVM doesn't release
mce_banks leading to memoryleak. Fix this issue by calling kfree()
for it when kcalloc() fails.

Fixes: 5e2d4e6c5ff6 ("KVM: x86: Add emulation for MSR_IA32_MCx_CTL2 MSRs.")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Message-Id: <20220901122300.22298-1-linmiaohe@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c