Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
virtio-input: free config list
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Gerd Hoffmann <[email protected]>
  • Loading branch information
elmarco committed Aug 7, 2016
1 parent df37dd6 commit 0137a55
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hw/input/virtio-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
};

/* ----------------------------------------------------------------- */
Expand Down

0 comments on commit 0137a55

Please sign in to comment.