KVM: x86/mmu: fix memoryleak in kvm_mmu_vendor_module_init()
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 23 Aug 2022 06:32:37 +0000 (14:32 +0800)
committerSean Christopherson <seanjc@google.com>
Wed, 24 Aug 2022 20:47:49 +0000 (13:47 -0700)
commitd7c9bfb9caaffd496ae44b258ec7c793677d3eeb
treec3cde73bdfc631cc9d47d4b9bd5dd72d0241a233
parent6aa5c47c351b22c21205c87977c84809cd015fcf
KVM: x86/mmu: fix memoryleak in kvm_mmu_vendor_module_init()

When register_shrinker() fails, KVM doesn't release the percpu counter
kvm_total_used_mmu_pages leading to memoryleak. Fix this issue by calling
percpu_counter_destroy() when register_shrinker() fails.

Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Link: https://lore.kernel.org/r/20220823063237.47299-1-linmiaohe@huawei.com
[sean: tweak shortlog and changelog]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/mmu.c