diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-07-15 10:55:12 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-08-08 00:00:28 +0400 |
commit | 0137a557aac07480ff8447ef372f0581af5ee65a (patch) | |
tree | d57b314263f8cb2fa9ee950f3f194886dd6f295c /hw/input | |
parent | df37dd6ffe49dc0da919c5034fb89e1f85e3c98f (diff) | |
download | qemu-0137a557aac07480ff8447ef372f0581af5ee65a.zip qemu-0137a557aac07480ff8447ef372f0581af5ee65a.tar.gz qemu-0137a557aac07480ff8447ef372f0581af5ee65a.tar.bz2 |
virtio-input: free config list
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 <marcandre.lureau@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/input')
-rw-r--r-- | hw/input/virtio-input.c | 11 |
1 files changed, 11 insertions, 0 deletions
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, }; /* ----------------------------------------------------------------- */ |