From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQH9z-0004YK-HR for qemu-devel@nongnu.org; Thu, 21 Jul 2016 12:49:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQH9v-0004i1-PN for qemu-devel@nongnu.org; Thu, 21 Jul 2016 12:49:19 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:34753) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQH9v-0004hw-KT for qemu-devel@nongnu.org; Thu, 21 Jul 2016 12:49:15 -0400 Received: by mail-oi0-x244.google.com with SMTP id c199so8213915oig.1 for ; Thu, 21 Jul 2016 09:49:15 -0700 (PDT) Sender: Corey Minyard From: minyard@acm.org Date: Thu, 21 Jul 2016 11:49:09 -0500 Message-Id: <1469119749-31181-4-git-send-email-minyard@acm.org> In-Reply-To: <1469119749-31181-1-git-send-email-minyard@acm.org> References: <1469119749-31181-1-git-send-email-minyard@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v2 3/3] wdt_ib700: Free timer 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?= , minyard@acm.org, Corey Minyard , "Richard W . M . Jones" From: Corey Minyard Add an unrealize function to free the timer allocated in the realize function and to delete the port memory added there, too. Signed-off-by: Corey Minyard Cc: Richard W.M. Jones Cc: Marc-André Lureau Reviewed-by: Richard W.M. Jones --- hw/watchdog/wdt_ib700.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c index 532afe8..23d4857 100644 --- a/hw/watchdog/wdt_ib700.c +++ b/hw/watchdog/wdt_ib700.c @@ -117,6 +117,15 @@ static void wdt_ib700_realize(DeviceState *dev, Error **errp) portio_list_add(&s->port_list, isa_address_space_io(&s->parent_obj), 0); } +static void wdt_ib700_unrealize(DeviceState *dev, Error **errp) +{ + IB700State *s = IB700(dev); + + timer_del(s->timer); + timer_free(s->timer); + portio_list_del(&s->port_list); +} + static void wdt_ib700_reset(DeviceState *dev) { IB700State *s = IB700(dev); @@ -136,6 +145,7 @@ static void wdt_ib700_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = wdt_ib700_realize; + dc->unrealize = wdt_ib700_unrealize; dc->reset = wdt_ib700_reset; dc->vmsd = &vmstate_ib700; set_bit(DEVICE_CATEGORY_MISC, dc->categories); -- 2.7.4