Received: from [140.186.70.92] (port=50081 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OK4V0-0007uW-7x for qemu-devel@nongnu.org; Thu, 03 Jun 2010 03:05:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OK4Ux-0002gG-PI for qemu-devel@nongnu.org; Thu, 03 Jun 2010 03:05:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37280) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OK4Ux-0002gA-Ge for qemu-devel@nongnu.org; Thu, 03 Jun 2010 03:05:51 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free() References: <20100527053558.GA31807@valinux.co.jp> <20100603005940.GJ12133@valinux.co.jp> Date: Thu, 03 Jun 2010 09:05:45 +0200 In-Reply-To: <20100603005940.GJ12133@valinux.co.jp> (Isaku Yamahata's message of "Thu, 3 Jun 2010 09:59:40 +0900") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: qemu-devel@nongnu.org Isaku Yamahata writes: > On Wed, Jun 02, 2010 at 05:01:13PM +0200, Markus Armbruster wrote: >> Isaku Yamahata writes: >> >> > BusState::name is allocated in qbus_create_inplace(). >> > So it should be freed by qbus_free(). >> >> Correct. >> >> > Signed-off-by: Isaku Yamahata >> > --- >> > hw/qdev.c | 1 + >> > 1 files changed, 1 insertions(+), 0 deletions(-) >> > >> > diff --git a/hw/qdev.c b/hw/qdev.c >> > index af17486..2845af5 100644 >> > --- a/hw/qdev.c >> > +++ b/hw/qdev.c >> > @@ -700,6 +700,7 @@ void qbus_free(BusState *bus) >> > QLIST_REMOVE(bus, sibling); >> > bus->parent->num_child_bus--; >> > } >> > + qemu_free((void*)bus->name); >> > if (bus->qdev_allocated) { >> > qemu_free(bus); >> > } >> >> Ugly, superfluous cast to void *. > > BusState::name is const char* so that the cast is necessary to drop const > qualifier. Otherwise gcc complains as follows. > > qemu/hw/qdev.c: In function 'qbus_free': > qemu/hw/qdev.c:657: error: passing argument 1 of 'qemu_free' discards qualifiers from pointer target type You're right. I keep suppressing all the silly trouble caused by const. Sorry for the noise.