From patchwork Tue Nov 29 01:49:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9450839 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04EB56071C for ; Tue, 29 Nov 2016 01:49:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECC0320649 for ; Tue, 29 Nov 2016 01:49:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEFAF27DF9; Tue, 29 Nov 2016 01:49:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E8ADF20649 for ; Tue, 29 Nov 2016 01:49:38 +0000 (UTC) Received: from localhost ([::1]:34081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBXY8-0003e1-P0 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Nov 2016 20:49:36 -0500 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date; bh=k/76KTlpqyvgf2hF6v1XeFDiX9HvM/b85JYJBRPTUMw=; b=Ysv4V5zY/kHGmNZ/JZRhb6vDpKXOPBaeZgQVXb3RHozuVRnoUrTbzBXCR8eeQKyT+z UvyWTxVIPTQ6EeEsXSw1K/K7fIaupAZa5Gk9DedZ0bFZs2J/ig6cMWVrf8gFA7/ZNDd3 xHjnOxvSEjqAMKZoEfmfeN+7BCORzf0paJY0wV+E6LBUl5ek5ctOfK1XsUapjGLoR0aZ CDtQ8sUL5RY5nWPxJPpgooO9dm27O2gOXjvNOvn1IWr1SzNNOyGDbbO4qvr9NVcRLNhk exZC0r7l1whw5KNTOmecF+7eKGshKAxuOYK7NQsk4u6gUBFQIWo4fZ7sgK3GcCS0NEBq SmOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date; bh=k/76KTlpqyvgf2hF6v1XeFDiX9HvM/b85JYJBRPTUMw=; b=KMXJ6cqpOlbqlgOZ3FCIFYp8PfMgiU9lzmrTQFQ2kxmihw2BQykLN1LAZwhcms75Dt 3TLE0Mp8NHe6JeOoxtPVf6QSZHqWp5t3ejybuJNPJHKpLeH5DpvDKu86kuA0Qysjk9j+ EMW/JgTlOx0+GQNztLFQtDScQ+dvHGmd7olNUM3IoOw+BB3Yyn9Rr294Slh1oebeG7tp ew3kwSvEVY728fP0t9c9HdYPblpUCGKZo4tLbhkEh+yMbCHpVuDiQ22uPB1i2sJ2LKvG HiiIKngB427DOYMcbXkj0JdamxUJQActyCOy8PrcE73YyuBaU1fgVE8cyEDtq13i/5jc gJQg== X-Gm-Message-State: AKaTC03a88KNZJpRpFOEniO/u0bYYDx5ABlgrap1HFeFZFz9/GRc9EG0J7xFhuILdXTmqw== X-Received: by 10.55.159.140 with SMTP id i134mr23936300qke.172.1480384156695; Mon, 28 Nov 2016 17:49:16 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id h47sm29812625qtc.27.2016.11.28.17.49.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 17:49:16 -0800 (PST) Message-ID: <583cde9c.3223ed0a.7f0c2.886e@mx.google.com> X-Google-Original-Message-ID: <1480384144-9621-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: rjones@redhat.com, qemu-devel@nongnu.org Date: Mon, 28 Nov 2016 17:49:04 -0800 X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH] watchdog: 6300esb: add exit function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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;