qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Isaku Yamahata <yamahata@valinux.co.jp>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free()
Date: Thu, 3 Jun 2010 09:59:40 +0900	[thread overview]
Message-ID: <20100603005940.GJ12133@valinux.co.jp> (raw)
In-Reply-To: <m3k4qh1nt2.fsf@blackfin.pond.sub.org>

On Wed, Jun 02, 2010 at 05:01:13PM +0200, Markus Armbruster wrote:
> Isaku Yamahata <yamahata@valinux.co.jp> writes:
> 
> > BusState::name is allocated in qbus_create_inplace().
> > So it should be freed by qbus_free().
> 
> Correct.
> 
> > Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> > ---
> >  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

-- 
yamahata

  reply	other threads:[~2010-06-03  1:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27  5:35 [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free() Isaku Yamahata
2010-06-02 15:01 ` Markus Armbruster
2010-06-03  0:59   ` Isaku Yamahata [this message]
2010-06-03  7:05     ` Markus Armbruster
2010-06-10 18:17 ` Blue Swirl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100603005940.GJ12133@valinux.co.jp \
    --to=yamahata@valinux.co.jp \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).