Message ID | 1575249568-52136-1-git-send-email-pannengyuan@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | virtio-input: fix memory leak in virtio_input_device_unrealize() | expand |
On Mon, Dec 2, 2019 at 5:20 AM <pannengyuan@huawei.com> wrote: > > From: PanNengyuan <pannengyuan@huawei.com> > > vdev->vq[i] is forgot to cleanup in > virtio_input_device_unrealize, the memory leak stack is as bellow: > > Direct leak of 3584 byte(s) in 1 object(s) allocated from: > #0 0x7f84a49f6560 in calloc (/usr/lib64/libasan.so.3+0xc7560) > #1 0x7f84a3b3e015 in g_malloc0 (/usr/lib64/libglib-2.0.so.0+0x50015) > #2 0x559c0f0b33e7 in virtio_add_queue /mnt/sdb/qemu-4.2.0-rc0/hw/virtio/virtio.c:2327 > #3 0x559c0f205c24 in virtio_input_device_realize /mnt/sdb/qemu-4.2.0-rc0/hw/input/virtio-input.c:262 > #4 0x559c0f0b06a7 in virtio_device_realize /mnt/sdb/qemu-4.2.0-rc0/hw/virtio/virtio.c:3504 > #5 0x559c0f1ba031 in device_set_realized /mnt/sdb/qemu-4.2.0-rc0/hw/core/qdev.c:876 > #6 0x559c0f32cedd in property_set_bool /mnt/sdb/qemu-4.2.0-rc0/qom/object.c:2080 > #7 0x559c0f3314ee in object_property_set_qobject /mnt/sdb/qemu-4.2.0-rc0/qom/qom-qobject.c:26 > > Direct leak of 3584 byte(s) in 1 object(s) allocated from: > #0 0x7f84a49f6560 in calloc (/usr/lib64/libasan.so.3+0xc7560) > #1 0x7f84a3b3e015 in g_malloc0 (/usr/lib64/libglib-2.0.so.0+0x50015) > #2 0x559c0f0b33e7 in virtio_add_queue /mnt/sdb/qemu-4.2.0-rc0/hw/virtio/virtio.c:2327 > #3 0x559c0f205c3f in virtio_input_device_realize /mnt/sdb/qemu-4.2.0-rc0/hw/input/virtio-input.c:263 > #4 0x559c0f0b06a7 in virtio_device_realize /mnt/sdb/qemu-4.2.0-rc0/hw/virtio/virtio.c:3504 > #5 0x559c0f1ba031 in device_set_realized /mnt/sdb/qemu-4.2.0-rc0/hw/core/qdev.c:876 > #6 0x559c0f32cedd in property_set_bool /mnt/sdb/qemu-4.2.0-rc0/qom/object.c:2080 > #7 0x559c0f3314ee in object_property_set_qobject /mnt/sdb/qemu-4.2.0-rc0/qom/qom-qobject.c:26 > > Reported-by: Euler Robot <euler.robot@huawei.com> > Signed-off-by: PanNengyuan <pannengyuan@huawei.com> This is already upstream: commit 509ec36c1e4c559e90115a16403dea8d92dff335 Author: Marc-André Lureau <marcandre.lureau@redhat.com> Date: Thu Nov 21 13:56:49 2019 +0400 virtio-input: fix memory leak on unrealize > --- > hw/input/virtio-input.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c > index 51617a5..da94da4 100644 > --- a/hw/input/virtio-input.c > +++ b/hw/input/virtio-input.c > @@ -288,6 +288,9 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp) > return; > } > } > + > + virtio_del_queue(vdev, 0); > + virtio_del_queue(vdev, 1); > virtio_cleanup(vdev); > } > > -- > 2.7.2.windows.1 > > >
diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index 51617a5..da94da4 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -288,6 +288,9 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp) return; } } + + virtio_del_queue(vdev, 0); + virtio_del_queue(vdev, 1); virtio_cleanup(vdev); }