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 5.10-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-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 09a1003ff5a10abef7dafb153b0fea05c19e3ff9 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 13bf3198d0ce..982529bcdf30 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5932,10 +5932,12 @@ int kvm_mmu_vendor_module_init(void) ret = register_shrinker(&mmu_shrinker); 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;