This is a note to let you know that I've just added the patch titled KVM: x86/mmu: fix memoryleak in kvm_mmu_vendor_module_init() to the 6.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: kvm-x86-mmu-fix-memoryleak-in-kvm_mmu_vendor_module_.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 80c076cb1e7ff649cd729910c9f9058780e124cc Author: Miaohe Lin <linmiaohe@xxxxxxxxxx> Date: Tue Aug 23 14:32:37 2022 +0800 KVM: x86/mmu: fix memoryleak in kvm_mmu_vendor_module_init() [ Upstream commit d7c9bfb9caaffd496ae44b258ec7c793677d3eeb ] 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@xxxxxxxxxx> Link: https://lore.kernel.org/r/20220823063237.47299-1-linmiaohe@xxxxxxxxxx [sean: tweak shortlog and changelog] Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 3552e6af3684..858bc53cfab4 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -6704,10 +6704,12 @@ int kvm_mmu_vendor_module_init(void) ret = register_shrinker(&mmu_shrinker, "x86-mmu"); if (ret) - goto out; + goto out_shrinker; return 0; +out_shrinker: + percpu_counter_destroy(&kvm_total_used_mmu_pages); out: mmu_destroy_caches(); return ret;