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: ab271bd4df
("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>
This commit is contained in:
parent
6aa5c47c35
commit
d7c9bfb9ca
|
@ -6702,10 +6702,12 @@ int kvm_mmu_vendor_module_init(void)
|
||||||
|
|
||||||
ret = register_shrinker(&mmu_shrinker, "x86-mmu");
|
ret = register_shrinker(&mmu_shrinker, "x86-mmu");
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out_shrinker;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_shrinker:
|
||||||
|
percpu_counter_destroy(&kvm_total_used_mmu_pages);
|
||||||
out:
|
out:
|
||||||
mmu_destroy_caches();
|
mmu_destroy_caches();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue