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

index a698a73de399bc0730a295d1a205205a2c003359..4addb34bf432b15c123d6a0343a59053c7ceb5c8 100644 (file)
@@ -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 = {