Received: from eggs.gnu.org ([2001:4830:134:3::10]:57780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBXXu-0003dw-Gb for qemu-devel@nongnu.org; Mon, 28 Nov 2016 20:49:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBXXq-0001xB-KB for qemu-devel@nongnu.org; Mon, 28 Nov 2016 20:49:22 -0500 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:32939) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cBXXq-0001wZ-CH for qemu-devel@nongnu.org; Mon, 28 Nov 2016 20:49:18 -0500 Received: by mail-qk0-x242.google.com with SMTP id x190so15770884qkb.0 for ; Mon, 28 Nov 2016 17:49:17 -0800 (PST) Message-ID: <583cde9c.3223ed0a.7f0c2.886e@mx.google.com> From: Li Qiang Date: Mon, 28 Nov 2016 17:49:04 -0800 Subject: [Qemu-devel] [PATCH] watchdog: 6300esb: add exit function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: rjones@redhat.com, qemu-devel@nongnu.org Cc: Li Qiang From: Li Qiang When the Intel 6300ESB watchdog is hot unplug. The timer allocated in realize isn't freed thus leaking memory leak. This patch avoid this through adding the exit function. Signed-off-by: Li Qiang --- hw/watchdog/wdt_i6300esb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c index a83d951..49b3cd1 100644 --- a/hw/watchdog/wdt_i6300esb.c +++ b/hw/watchdog/wdt_i6300esb.c @@ -428,6 +428,14 @@ static void i6300esb_realize(PCIDevice *dev, Error **errp) /* qemu_register_coalesced_mmio (addr, 0x10); ? */ } +static void i6300esb_exit(PCIDevice *dev) +{ + I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); + + timer_del(d->timer); + timer_free(d->timer); +} + static WatchdogTimerModel model = { .wdt_name = "i6300esb", .wdt_description = "Intel 6300ESB", @@ -441,6 +449,7 @@ static void i6300esb_class_init(ObjectClass *klass, void *data) k->config_read = i6300esb_config_read; k->config_write = i6300esb_config_write; k->realize = i6300esb_realize; + k->exit = i6300esb_exit; k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ESB_9; k->class_id = PCI_CLASS_SYSTEM_OTHER; -- 1.8.3.1