[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 27/37] virtio-input: free config list
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v2 27/37] virtio-input: free config list |
Date: |
Thu, 28 Jul 2016 18:37:58 +0400 |
From: Marc-André Lureau <address@hidden>
Clear the list when finalizing. The list is created during realize with
virtio_input_idstr_config() and later by further calls to
virtio_input_init_config() and virtio_input_add_config().
This leak can be reproduced with device-introspect-test -p
/x86_64/device/introspect/concrete.
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/input/virtio-input.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index a87fd68..ccdf730 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -270,6 +270,16 @@ static void virtio_input_device_realize(DeviceState *dev,
Error **errp)
vinput->sts = virtio_add_queue(vdev, 64, virtio_input_handle_sts);
}
+static void virtio_input_finalize(Object *obj)
+{
+ VirtIOInput *vinput = VIRTIO_INPUT(obj);
+ VirtIOInputConfig *cfg, *next;
+
+ QTAILQ_FOREACH_SAFE(cfg, &vinput->cfg_list, node, next) {
+ QTAILQ_REMOVE(&vinput->cfg_list, cfg, node);
+ g_free(cfg);
+ }
+}
static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
{
VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev);
@@ -318,6 +328,7 @@ static const TypeInfo virtio_input_info = {
.class_size = sizeof(VirtIOInputClass),
.class_init = virtio_input_class_init,
.abstract = true,
+ .instance_finalize = virtio_input_finalize,
};
/* ----------------------------------------------------------------- */
--
2.9.0
- [Qemu-devel] [PATCH v2 19/37] char: disconnect peer when qemu_chr_free(), (continued)
- [Qemu-devel] [PATCH v2 19/37] char: disconnect peer when qemu_chr_free(), marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 20/37] char: free MuxDriver when closing, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 21/37] tests: fix qom-test leaks, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 22/37] pc: free i8259, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 23/37] pc: keep gsi reference, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 24/37] ahci: free irqs array, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 25/37] sd: free timer, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 26/37] qjson: free str, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 27/37] virtio-input: free config list,
marcandre . lureau <=
- [Qemu-devel] [PATCH v2 28/37] ipmi: free extern timer, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 29/37] usb: free USBDevice.strings, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 30/37] tests: free a bunch of qmp responses, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 31/37] usb: free leaking path, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 32/37] bus: simplify name handling, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 33/37] tests: add qtest_add_data_func_full, marcandre . lureau, 2016/07/28
- [Qemu-devel] [PATCH v2 34/37] tests: pc-cpu-test leaks fixes, marcandre . lureau, 2016/07/28