]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
LoongArch: KVM: Fix kvm_device leak in kvm_ipi_destroy()
authorQiang Ma <maqianga@uniontech.com>
Sat, 17 Jan 2026 02:57:02 +0000 (10:57 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 17 Jan 2026 02:57:02 +0000 (10:57 +0800)
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.

Cc: stable@vger.kernel.org
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Qiang Ma <maqianga@uniontech.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kvm/intc/ipi.c

index 05cefd29282e8e66d71a8ada4c6a7fc83122805e..1058c13dba7f4f781eacf6235532eb338dc08edc 100644 (file)
@@ -459,6 +459,7 @@ 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);
+       kfree(dev);
 }
 
 static struct kvm_device_ops kvm_ipi_dev_ops = {