* [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy
@ 2025-12-26 15:07 Qiang Ma
2025-12-26 15:07 ` [PATCH 1/3] LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy Qiang Ma
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Qiang Ma @ 2025-12-26 15:07 UTC (permalink / raw)
To: zhaotianrui, maobibo, chenhuacai, kernel
Cc: kvm, loongarch, linux-kernel, Qiang Ma
In kvm_ioctl_create_device(), kvm_device has allocated memory,
kvm_device->destroy() seems to be supposed to free its kvm_device
struct, but kvm_pch_pic_destroy() is not currently doing this,
that would lead to a memory leak.
So, fix it.
Qiang Ma (3):
LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy
LoongArch: KVM: Fix kvm_device leak in kvm_ipi_destroy
LoongArch: KVM: Fix kvm_device leak in kvm_eiointc_destroy
arch/loongarch/kvm/intc/eiointc.c | 2 ++
arch/loongarch/kvm/intc/ipi.c | 2 ++
arch/loongarch/kvm/intc/pch_pic.c | 2 ++
3 files changed, 6 insertions(+)
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy
2025-12-26 15:07 [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy Qiang Ma
@ 2025-12-26 15:07 ` Qiang Ma
2025-12-26 15:07 ` [PATCH 2/3] LoongArch: KVM: Fix kvm_device leak in kvm_ipi_destroy Qiang Ma
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Qiang Ma @ 2025-12-26 15:07 UTC (permalink / raw)
To: zhaotianrui, maobibo, chenhuacai, kernel
Cc: kvm, loongarch, linux-kernel, Qiang Ma
In kvm_ioctl_create_device(), kvm_device has allocated memory,
kvm_device->destroy() seems to be supposed to free its kvm_device
struct, but kvm_pch_pic_destroy() is not currently doing this,
that would lead to a memory leak.
So, fix it.
Signed-off-by: Qiang Ma <maqianga@uniontech.com>
---
arch/loongarch/kvm/intc/pch_pic.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c
index a698a73de399..f710c904b40c 100644
--- a/arch/loongarch/kvm/intc/pch_pic.c
+++ b/arch/loongarch/kvm/intc/pch_pic.c
@@ -475,6 +475,8 @@ static void kvm_pch_pic_destroy(struct kvm_device *dev)
/* unregister pch pic device and free it's memory */
kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &s->device);
kfree(s);
+ /* alloc by kvm_ioctl_create_device, free by .destroy */
+ kfree(dev);
}
static struct kvm_device_ops kvm_pch_pic_dev_ops = {
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] LoongArch: KVM: Fix kvm_device leak in kvm_ipi_destroy
2025-12-26 15:07 [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy Qiang Ma
2025-12-26 15:07 ` [PATCH 1/3] LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy Qiang Ma
@ 2025-12-26 15:07 ` Qiang Ma
2025-12-26 15:07 ` [PATCH 3/3] LoongArch: KVM: Fix kvm_device leak in kvm_eiointc_destroy Qiang Ma
2025-12-31 6:32 ` [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy Bibo Mao
3 siblings, 0 replies; 5+ messages in thread
From: Qiang Ma @ 2025-12-26 15:07 UTC (permalink / raw)
To: zhaotianrui, maobibo, chenhuacai, kernel
Cc: kvm, loongarch, linux-kernel, Qiang Ma
In kvm_ioctl_create_device(), kvm_device has allocated memory,
kvm_device->destroy() seems to be supposed to free its kvm_device
struct, but kvm_ipi_destroy() is not currently doing this, that
would lead to a memory leak.
So, fix it.
Signed-off-by: Qiang Ma <maqianga@uniontech.com>
---
arch/loongarch/kvm/intc/ipi.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/loongarch/kvm/intc/ipi.c b/arch/loongarch/kvm/intc/ipi.c
index 05cefd29282e..77169bf49f3f 100644
--- a/arch/loongarch/kvm/intc/ipi.c
+++ b/arch/loongarch/kvm/intc/ipi.c
@@ -459,6 +459,8 @@ static void kvm_ipi_destroy(struct kvm_device *dev)
ipi = kvm->arch.ipi;
kvm_io_bus_unregister_dev(kvm, KVM_IOCSR_BUS, &ipi->device);
kfree(ipi);
+ /* alloc by kvm_ioctl_create_device, free by .destroy */
+ kfree(dev);
}
static struct kvm_device_ops kvm_ipi_dev_ops = {
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] LoongArch: KVM: Fix kvm_device leak in kvm_eiointc_destroy
2025-12-26 15:07 [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy Qiang Ma
2025-12-26 15:07 ` [PATCH 1/3] LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy Qiang Ma
2025-12-26 15:07 ` [PATCH 2/3] LoongArch: KVM: Fix kvm_device leak in kvm_ipi_destroy Qiang Ma
@ 2025-12-26 15:07 ` Qiang Ma
2025-12-31 6:32 ` [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy Bibo Mao
3 siblings, 0 replies; 5+ messages in thread
From: Qiang Ma @ 2025-12-26 15:07 UTC (permalink / raw)
To: zhaotianrui, maobibo, chenhuacai, kernel
Cc: kvm, loongarch, linux-kernel, Qiang Ma
In kvm_ioctl_create_device(), kvm_device has allocated memory,
kvm_device->destroy() seems to be supposed to free its kvm_device
struct, but kvm_eiointc_destroy() is not currently doing this,
that would lead to a memory leak.
So, fix it.
Signed-off-by: Qiang Ma <maqianga@uniontech.com>
---
arch/loongarch/kvm/intc/eiointc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
index 29886876143f..cb94c7e8267a 100644
--- a/arch/loongarch/kvm/intc/eiointc.c
+++ b/arch/loongarch/kvm/intc/eiointc.c
@@ -679,6 +679,8 @@ static void kvm_eiointc_destroy(struct kvm_device *dev)
kvm_io_bus_unregister_dev(kvm, KVM_IOCSR_BUS, &eiointc->device);
kvm_io_bus_unregister_dev(kvm, KVM_IOCSR_BUS, &eiointc->device_vext);
kfree(eiointc);
+ /* alloc by kvm_ioctl_create_device, free by .destroy */
+ kfree(dev);
}
static struct kvm_device_ops kvm_eiointc_dev_ops = {
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy
2025-12-26 15:07 [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy Qiang Ma
` (2 preceding siblings ...)
2025-12-26 15:07 ` [PATCH 3/3] LoongArch: KVM: Fix kvm_device leak in kvm_eiointc_destroy Qiang Ma
@ 2025-12-31 6:32 ` Bibo Mao
3 siblings, 0 replies; 5+ messages in thread
From: Bibo Mao @ 2025-12-31 6:32 UTC (permalink / raw)
To: Qiang Ma, zhaotianrui, chenhuacai, kernel; +Cc: kvm, loongarch, linux-kernel
Hi qiang,
Thanks for the patch, it looks good to me.
For the whole series.
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Regards
Bibo Mao
On 2025/12/26 下午11:07, Qiang Ma wrote:
> In kvm_ioctl_create_device(), kvm_device has allocated memory,
> kvm_device->destroy() seems to be supposed to free its kvm_device
> struct, but kvm_pch_pic_destroy() is not currently doing this,
> that would lead to a memory leak.
>
> So, fix it.
>
> Qiang Ma (3):
> LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy
> LoongArch: KVM: Fix kvm_device leak in kvm_ipi_destroy
> LoongArch: KVM: Fix kvm_device leak in kvm_eiointc_destroy
>
> arch/loongarch/kvm/intc/eiointc.c | 2 ++
> arch/loongarch/kvm/intc/ipi.c | 2 ++
> arch/loongarch/kvm/intc/pch_pic.c | 2 ++
> 3 files changed, 6 insertions(+)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-12-31 6:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-26 15:07 [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy Qiang Ma
2025-12-26 15:07 ` [PATCH 1/3] LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy Qiang Ma
2025-12-26 15:07 ` [PATCH 2/3] LoongArch: KVM: Fix kvm_device leak in kvm_ipi_destroy Qiang Ma
2025-12-26 15:07 ` [PATCH 3/3] LoongArch: KVM: Fix kvm_device leak in kvm_eiointc_destroy Qiang Ma
2025-12-31 6:32 ` [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy Bibo Mao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®