kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
PATCH 1/1 kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
When register_shrinker() fails, we forgot to release the percpu counter kvm_total_used_mmu_pages leading to memoryleak. Fix this issue by calling percpu_counter_destroy() when register_shrinker() fails.
--- arch/x86/kvm/mmu/mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/mmu/mmu.c +3 -1
@@ -6702,10 +6702,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;
Signature · 1 line
2.23.0
Nit for future patches, please use
KVM: x86/mmu:
for the scope.
Quoted 7 lines · Miaohe Lin
When
register_shrinker()fails, we forgot to release the percpu counterkvm_total_used_mmu_pagesleading to memoryleak. Fix this issue by callingpercpu_counter_destroy()whenregister_shrinker()fails.Fixes ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")Signed-off-by Miaohe Lin <[email protected]>---
Quoted 5 lines · Sean Christopherson
Nit for future patches, please use
KVM: x86/mmu:
for the scope.
Will take care of it.
Quoted 11 lines · Miaohe Lin
Quoted 7 lines
When
register_shrinker()fails, we forgot to release the percpu counterkvm_total_used_mmu_pagesleading to memoryleak. Fix this issue by callingpercpu_counter_destroy()whenregister_shrinker()fails.Fixes ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")Signed-off-by Miaohe Lin <[email protected]>---
Reviewed-by Sean Christopherson <[email protected]>
Many thanks for your review.
Thanks,
Miaohe Lin
Quoted 7 lines · Miaohe Lin
When
register_shrinker()fails, we forgot to release the percpu counterkvm_total_used_mmu_pagesleading to memoryleak. Fix this issue by callingpercpu_counter_destroy()whenregister_shrinker()fails.Fixes ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")Signed-off-by Miaohe Lin <[email protected]>---
Pushed to branch for_paolo/6.1 at:
https://github.com/sean-jc/linux.git
Unless you hear otherwise, it will make its way to kvm/queue "soon".
Note, the commit IDs are not guaranteed to be stable.
Quoted 10 lines · Sean Christopherson
Quoted 8 lines · Miaohe Lin
When
register_shrinker()fails, we forgot to release the percpu counter
kvm_total_used_mmu_pagesleading to memoryleak. Fix this issue by callingpercpu_counter_destroy()whenregister_shrinker()fails.Fixes ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")Signed-off-by Miaohe Lin <[email protected]>---
Quoted 7 lines
Pushed to branch
for_paolo/6.1at:https://github.com/sean-jc/linux.git
Unless you hear otherwise, it will make its way to kvm/queue "soon".
Note, the commit IDs are not guaranteed to be stable.
Sorry for late reply.
The commit message has "we". Should we get rid of it?
Signature · 2 lines
Thanks, -Kai
Sean Christopherson
maintainerQuoted 15 lines · Kai
Quoted 14 lines · Sean Christopherson
Quoted 8 lines · Miaohe Lin
When
register_shrinker()fails, we forgot to release the percpu counter
kvm_total_used_mmu_pagesleading to memoryleak. Fix this issue by callingpercpu_counter_destroy()whenregister_shrinker()fails.Fixes ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")Signed-off-by Miaohe Lin <[email protected]>---
Pushed to branch
for_paolo/6.1at:
Quoted 7 lines
Quoted 3 lines
Unless you hear otherwise, it will make its way to kvm/queue "soon".
Note, the commit IDs are not guaranteed to be stable.
Sorry for late reply.
The commit message has "we". Should we get rid of it?
Avoiding pronouns is obviously my preference, but sometimes even I set aside my crusade to move things along :-)
Quoted 21 lines · Kai
Quoted 20 lines · Sean Christopherson
Quoted 19 lines · Miaohe Lin
Quoted 11 lines
When
register_shrinker()fails, we forgot to release the percpu counter
kvm_total_used_mmu_pagesleading to memoryleak. Fix this issue by callingpercpu_counter_destroy()whenregister_shrinker()fails.Fixes ab271bd4dfd5 ("x86: kvm: propagate register_shrinker returncode")
Signed-off-by Miaohe Lin <[email protected]>---
Pushed to branch
for_paolo/6.1at:https://github.com/sean-jc/linux.git
Unless you hear otherwise, it will make its way to kvm/queue "soon".
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Note, the commit IDs are not guaranteed to be stable.
Sorry for late reply.
The commit message has "we". Should we get rid of it?
Avoiding pronouns is obviously my preference, but sometimes even I set aside my crusade to move things along :-)
Yeah sure. I was replying just in case you didn't notice it :)
Quoted 23 lines · Kai
Quoted 23 lines · Kai
Quoted 22 lines · Sean Christopherson
Quoted 20 lines · Miaohe Lin
Quoted 11 lines
When
register_shrinker()fails, we forgot to release the percpu counter
kvm_total_used_mmu_pagesleading to memoryleak. Fix this issue by callingpercpu_counter_destroy()whenregister_shrinker()fails.Fixes ab271bd4dfd5 ("x86: kvm: propagate register_shrinker returncode")
Signed-off-by Miaohe Lin <[email protected]>---
Pushed to branch
for_paolo/6.1at:https://github.com/sean-jc/linux.git
Unless you hear otherwise, it will make its way to kvm/queue "soon".
Note, the commit IDs are not guaranteed to be stable.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Sorry for late reply.
The commit message has "we". Should we get rid of it?
Avoiding pronouns is obviously my preference, but sometimes even I set aside my crusade to move things along :-)
Yeah sure. I was replying just in case you didn't notice it :)
Please ignore my previous question in another thread. I just saw this patch. ;)
Many thanks.
Quoted 3 lines
.
Quoted 15 lines · Kai
Quoted 14 lines · Sean Christopherson
Quoted 8 lines · Miaohe Lin
When
register_shrinker()fails, we forgot to release the percpu counter
kvm_total_used_mmu_pagesleading to memoryleak. Fix this issue by callingpercpu_counter_destroy()whenregister_shrinker()fails.Fixes ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")Signed-off-by Miaohe Lin <[email protected]>---
Pushed to branch
for_paolo/6.1at:
Quoted 7 lines
Quoted 3 lines
Unless you hear otherwise, it will make its way to kvm/queue "soon".
Note, the commit IDs are not guaranteed to be stable.
Sorry for late reply.
The commit message has "we". Should we get rid of it?
Sean has kindly tweaked the commit message. Many thanks both.
BTW: Is it unsuitable to use "we" in the commit message? If so, I will try to not use it in later patches.
Thanks,
Miaohe Lin