From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPQp4-0001Zs-Fp for qemu-devel@nongnu.org; Tue, 19 Jul 2016 04:56:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPQoz-0007oV-FK for qemu-devel@nongnu.org; Tue, 19 Jul 2016 04:56:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPQoz-0007oP-9P for qemu-devel@nongnu.org; Tue, 19 Jul 2016 04:56:09 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1FCF78EAD for ; Tue, 19 Jul 2016 08:56:08 +0000 (UTC) From: marcandre.lureau@redhat.com Date: Tue, 19 Jul 2016 12:54:23 +0400 Message-Id: <20160719085432.4572-29-marcandre.lureau@redhat.com> In-Reply-To: <20160719085432.4572-1-marcandre.lureau@redhat.com> References: <20160719085432.4572-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 28/37] virtio-input: free config list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?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(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/input/virtio-input-hid.c | 1 + hw/input/virtio-input.c | 10 ++++++++++ include/hw/virtio/virtio-input.h | 1 + 3 files changed, 12 insertions(+) diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 3ee0c18..0e5596e 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -340,6 +340,7 @@ static const TypeInfo virtio_input_hid_info =3D { .instance_size =3D sizeof(VirtIOInputHID), .class_init =3D virtio_input_hid_class_init, .abstract =3D true, + .instance_finalize =3D virtio_input_finalize, }; =20 /* ----------------------------------------------------------------- */ diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index edf6990..36a7d5e 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -285,6 +285,16 @@ static void virtio_input_device_realize(DeviceState = *dev, Error **errp) virtio_input_save, virtio_input_load, vinput); } =20 +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); diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-= input.h index 55db310..8fd790f 100644 --- a/include/hw/virtio/virtio-input.h +++ b/include/hw/virtio/virtio-input.h @@ -104,5 +104,6 @@ void virtio_input_add_config(VirtIOInput *vinput, virtio_input_config *config); void virtio_input_idstr_config(VirtIOInput *vinput, uint8_t select, const char *string); +void virtio_input_finalize(Object *obj); =20 #endif /* QEMU_VIRTIO_INPUT_H */ --=20 2.9.0