Skip to content

Commit fc53a66

Browse files
JohnsPonygregkh
authored andcommitted
LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy()
commit 1cf342a upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5defcc2 commit fc53a66

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

arch/loongarch/kvm/intc/pch_pic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ static void kvm_pch_pic_destroy(struct kvm_device *dev)
475475
/* unregister pch pic device and free it's memory */
476476
kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &s->device);
477477
kfree(s);
478+
kfree(dev);
478479
}
479480

480481
static struct kvm_device_ops kvm_pch_pic_dev_ops = {

0 commit comments

Comments
 (0)