projects/linux·commit 7d8553fc

LoongArch: KVM: Fix kvm_device leak in kvm_eiointc_destroy()

7d8553fc · Qiang Ma <[email protected]> · 2026-01-17 10:57:02 +08:00

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.

Cc: [email protected]
Reviewed-by: Bibo Mao <[email protected]>
Signed-off-by: Qiang Ma <[email protected]>
Signed-off-by: Huacai Chen <[email protected]>
Commit
7d8553fc75aefa7ec936af0cf8443ff90b51732e
Parents
0bf58cb7

Changes

1 files changed · +1 −0

FileStatusAddDelContent
arch/loongarch/kvm/intc/eiointc.cmodified+1−0View file

arch/loongarch/kvm/intc/eiointc.c

View file
diff --git a/arch/loongarch/kvm/intc/eiointc.c b/arch/loongarch/kvm/intc/eiointc.c
index 2988687..dfaf6cc 100644
--- a/arch/loongarch/kvm/intc/eiointc.c
+++ b/arch/loongarch/kvm/intc/eiointc.c
@@ -679,6 +679,7 @@ 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);
+ kfree(dev);
}
static struct kvm_device_ops kvm_eiointc_dev_ops = {