From: Qiang Ma <maqianga@uniontech.com>
To: zhaotianrui@loongson.cn, maobibo@loongson.cn,
chenhuacai@kernel.org, kernel@xen0n.name
Cc: kvm@vger.kernel.org, loongarch@lists.linux.dev,
linux-kernel@vger.kernel.org, Qiang Ma <maqianga@uniontech.com>
Subject: [PATCH 3/3] LoongArch: KVM: Fix kvm_device leak in kvm_eiointc_destroy
Date: Fri, 26 Dec 2025 23:07:06 +0800 [thread overview]
Message-ID: <20251226150706.2511127-4-maqianga@uniontech.com> (raw)
In-Reply-To: <20251226150706.2511127-1-maqianga@uniontech.com>
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
next prev parent reply other threads:[~2025-12-26 15:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-12-31 6:32 ` [PATCH 0/3] LoongArch: KVM: Fix kvm_device leak in kvm_{pch_pic|ipi|eiointc}_destroy Bibo Mao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251226150706.2511127-4-maqianga@uniontech.com \
--to=maqianga@uniontech.com \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
--cc=zhaotianrui@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®