* [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
@ 2022-08-23 6:32 Miaohe Lin
2022-08-24 15:44 ` Sean Christopherson
2022-08-30 21:40 ` Sean Christopherson
0 siblings, 2 replies; 9+ messages in thread
From: Miaohe Lin @ 2022-08-23 6:32 UTC (permalink / raw)
To: seanjc, pbonzini, tglx, mingo, bp, dave.hansen
Cc: x86, hpa, kvm, linux-kernel, linmiaohe
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.
Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
arch/x86/kvm/mmu/mmu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index e418ef3ecfcb..d25d55b1f0b5 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -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;
--
2.23.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
2022-08-23 6:32 [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init() Miaohe Lin
@ 2022-08-24 15:44 ` Sean Christopherson
2022-08-25 1:43 ` Miaohe Lin
2022-08-30 21:40 ` Sean Christopherson
1 sibling, 1 reply; 9+ messages in thread
From: Sean Christopherson @ 2022-08-24 15:44 UTC (permalink / raw)
To: Miaohe Lin
Cc: pbonzini, tglx, mingo, bp, dave.hansen, x86, hpa, kvm, linux-kernel
Nit for future patches, please use
KVM: x86/mmu:
for the scope.
On Tue, Aug 23, 2022, Miaohe Lin wrote:
> 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.
>
> Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
Reviewed-by: Sean Christopherson <seanjc@google.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
2022-08-24 15:44 ` Sean Christopherson
@ 2022-08-25 1:43 ` Miaohe Lin
0 siblings, 0 replies; 9+ messages in thread
From: Miaohe Lin @ 2022-08-25 1:43 UTC (permalink / raw)
To: Sean Christopherson
Cc: pbonzini, tglx, mingo, bp, dave.hansen, x86, hpa, kvm, linux-kernel
On 2022/8/24 23:44, Sean Christopherson wrote:
> Nit for future patches, please use
>
> KVM: x86/mmu:
>
> for the scope.
Will take care of it.
>
> On Tue, Aug 23, 2022, Miaohe Lin wrote:
>> 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.
>>
>> Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>
> Reviewed-by: Sean Christopherson <seanjc@google.com>
Many thanks for your review.
Thanks,
Miaohe Lin
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
2022-08-23 6:32 [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init() Miaohe Lin
2022-08-24 15:44 ` Sean Christopherson
@ 2022-08-30 21:40 ` Sean Christopherson
2022-08-30 22:42 ` Huang, Kai
1 sibling, 1 reply; 9+ messages in thread
From: Sean Christopherson @ 2022-08-30 21:40 UTC (permalink / raw)
To: Miaohe Lin
Cc: pbonzini, tglx, mingo, bp, dave.hansen, x86, hpa, kvm, linux-kernel
On Tue, Aug 23, 2022, Miaohe Lin wrote:
> 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.
>
> Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
2022-08-30 21:40 ` Sean Christopherson
@ 2022-08-30 22:42 ` Huang, Kai
2022-08-30 22:52 ` Sean Christopherson
2022-08-31 1:53 ` Miaohe Lin
0 siblings, 2 replies; 9+ messages in thread
From: Huang, Kai @ 2022-08-30 22:42 UTC (permalink / raw)
To: linmiaohe, Christopherson,, Sean
Cc: x86, dave.hansen, hpa, mingo, tglx, bp, kvm, pbonzini, linux-kernel
On Tue, 2022-08-30 at 21:40 +0000, Sean Christopherson wrote:
> On Tue, Aug 23, 2022, Miaohe Lin wrote:
> > 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.
> >
> > Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")
> > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> > ---
>
> 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.
Sorry for late reply.
The commit message has "we". Should we get rid of it?
--
Thanks,
-Kai
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
2022-08-30 22:42 ` Huang, Kai
@ 2022-08-30 22:52 ` Sean Christopherson
2022-08-31 1:07 ` Huang, Kai
2022-08-31 1:53 ` Miaohe Lin
1 sibling, 1 reply; 9+ messages in thread
From: Sean Christopherson @ 2022-08-30 22:52 UTC (permalink / raw)
To: Huang, Kai
Cc: linmiaohe, x86, dave.hansen, hpa, mingo, tglx, bp, kvm, pbonzini,
linux-kernel
On Tue, Aug 30, 2022, Huang, Kai wrote:
> On Tue, 2022-08-30 at 21:40 +0000, Sean Christopherson wrote:
> > On Tue, Aug 23, 2022, Miaohe Lin wrote:
> > > 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.
> > >
> > > Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")
> > > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> > > ---
> >
> > 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.
>
> 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 :-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
2022-08-30 22:52 ` Sean Christopherson
@ 2022-08-31 1:07 ` Huang, Kai
2022-08-31 1:58 ` Miaohe Lin
0 siblings, 1 reply; 9+ messages in thread
From: Huang, Kai @ 2022-08-31 1:07 UTC (permalink / raw)
To: Christopherson,, Sean
Cc: linmiaohe, x86, dave.hansen, hpa, mingo, tglx, bp, kvm, pbonzini,
linux-kernel
> On Tue, Aug 30, 2022, Huang, Kai wrote:
> > On Tue, 2022-08-30 at 21:40 +0000, Sean Christopherson wrote:
> > > On Tue, Aug 23, 2022, Miaohe Lin wrote:
> > > > 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.
> > > >
> > > > Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return
> > > > code")
> > > > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> > > > ---
> > >
> > > 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.
> >
> > 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 :)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
2022-08-30 22:42 ` Huang, Kai
2022-08-30 22:52 ` Sean Christopherson
@ 2022-08-31 1:53 ` Miaohe Lin
1 sibling, 0 replies; 9+ messages in thread
From: Miaohe Lin @ 2022-08-31 1:53 UTC (permalink / raw)
To: Huang, Kai, Christopherson,, Sean
Cc: x86, dave.hansen, hpa, mingo, tglx, bp, kvm, pbonzini, linux-kernel
On 2022/8/31 6:42, Huang, Kai wrote:
> On Tue, 2022-08-30 at 21:40 +0000, Sean Christopherson wrote:
>> On Tue, Aug 23, 2022, Miaohe Lin wrote:
>>> 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.
>>>
>>> Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return code")
>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>>> ---
>>
>> 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.
>
> 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init()
2022-08-31 1:07 ` Huang, Kai
@ 2022-08-31 1:58 ` Miaohe Lin
0 siblings, 0 replies; 9+ messages in thread
From: Miaohe Lin @ 2022-08-31 1:58 UTC (permalink / raw)
To: Huang, Kai, Christopherson,, Sean
Cc: x86, dave.hansen, hpa, mingo, tglx, bp, kvm, pbonzini, linux-kernel
On 2022/8/31 9:07, Huang, Kai wrote:
>> On Tue, Aug 30, 2022, Huang, Kai wrote:
>>> On Tue, 2022-08-30 at 21:40 +0000, Sean Christopherson wrote:
>>>> On Tue, Aug 23, 2022, Miaohe Lin wrote:
>>>>> 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.
>>>>>
>>>>> Fixes: ab271bd4dfd5 ("x86: kvm: propagate register_shrinker return
>>>>> code")
>>>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>>>>> ---
>>>>
>>>> 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.
>>>
>>> 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.
>
> .
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-08-31 1:58 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-23 6:32 [PATCH] kvm: x86: mmu: fix memoryleak in kvm_mmu_vendor_module_init() Miaohe Lin
2022-08-24 15:44 ` Sean Christopherson
2022-08-25 1:43 ` Miaohe Lin
2022-08-30 21:40 ` Sean Christopherson
2022-08-30 22:42 ` Huang, Kai
2022-08-30 22:52 ` Sean Christopherson
2022-08-31 1:07 ` Huang, Kai
2022-08-31 1:58 ` Miaohe Lin
2022-08-31 1:53 ` Miaohe Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).