projects/linux·commit 1cf342a7

LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy()

1cf342a7 · Qiang Ma <[email protected]> · 2026-01-17 10:57:03 +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_pch_pic_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
1cf342a7c3adc5877837b53bbceb5cc9eff60bbf
Parents
7d8553fc

Changes

1 files changed · +1 −0

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

arch/loongarch/kvm/intc/pch_pic.c

View file
diff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c
index a698a73..4addb34 100644
--- a/arch/loongarch/kvm/intc/pch_pic.c
+++ b/arch/loongarch/kvm/intc/pch_pic.c
@@ -475,6 +475,7 @@ 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);
+ kfree(dev);
}
static struct kvm_device_ops kvm_pch_pic_dev_ops = {