Received: from eggs.gnu.org ([2001:4830:134:3::10]:47286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBfz8-0007i6-FZ for qemu-devel@nongnu.org; Tue, 29 Nov 2016 05:50:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBfz5-0004TX-EJ for qemu-devel@nongnu.org; Tue, 29 Nov 2016 05:50:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:6818) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cBfz5-0004Sr-8f for qemu-devel@nongnu.org; Tue, 29 Nov 2016 05:49:59 -0500 From: Markus Armbruster References: <583cde9c.3223ed0a.7f0c2.886e@mx.google.com> <20161129083943.GP11243@redhat.com> Date: Tue, 29 Nov 2016 11:49:55 +0100 In-Reply-To: (Li Qiang's message of "Tue, 29 Nov 2016 16:56:55 +0800") Message-ID: <8760n6v9uz.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] watchdog: 6300esb: add exit function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Li Qiang Cc: "Richard W.M. Jones" , Li Qiang , qemu-devel@nongnu.org Li Qiang writes: > Hi > > 2016-11-29 16:39 GMT+08:00 Richard W.M. Jones : > >> On Mon, Nov 28, 2016 at 05:49:04PM -0800, Li Qiang wrote: >> > 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. >> >> I will just note that the real hardware is not hot-pluggable. However >> we don't need to stick to the real hardware capabilities, so that's OK. >> >> > > If the hardware is not hot-pluggable, we can set dc->hotpluggable = false. > > >> 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; >> >> The wdt_diag288.c file seems to use k->unrealize for this purpose. >> I don't know which is correct however. >> >> >> > wdt_diag288.c uses dc->unrealize for DeviceClass, while k->exit if for > PCIDeviceClass. Method exit() is deprecated, please use unrealize() in new code. [...]