Received: from eggs.gnu.org ([2001:4830:134:3::10]:59866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWUL7-0000B3-D3 for qemu-devel@nongnu.org; Sun, 07 Aug 2016 16:06:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWUL4-0007KU-JW for qemu-devel@nongnu.org; Sun, 07 Aug 2016 16:06:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWUL4-0007KQ-Db for qemu-devel@nongnu.org; Sun, 07 Aug 2016 16:06:26 -0400 From: marcandre.lureau@redhat.com Date: Mon, 8 Aug 2016 00:05:58 +0400 Message-Id: <20160807200601.25905-7-marcandre.lureau@redhat.com> In-Reply-To: <20160807200601.25905-1-marcandre.lureau@redhat.com> References: <20160807200601.25905-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL for-2.7 6/9] virtio-input: free config list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau 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=C3=A9 Lureau Reviewed-by: Gerd Hoffmann --- 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 =3D virtio_add_queue(vdev, 64, virtio_input_handle_sts); } =20 +static void virtio_input_finalize(Object *obj) +{ + VirtIOInput *vinput =3D 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 =3D VIRTIO_INPUT_GET_CLASS(dev); @@ -318,6 +328,7 @@ static const TypeInfo virtio_input_info =3D { .class_size =3D sizeof(VirtIOInputClass), .class_init =3D virtio_input_class_init, .abstract =3D true, + .instance_finalize =3D virtio_input_finalize, }; =20 /* ----------------------------------------------------------------- */ --=20 2.9.0