Patch "KVM: x86/mmu: fix memoryleak in kvm_mmu_vendor_module_init()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.15-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.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8571e283c27ecb4b6270781434f9bdc9e736a5b4
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 ba1749a770eb..23839c90f44c 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -6147,10 +6147,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;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux