qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free()
@ 2010-05-27  5:35 Isaku Yamahata
  2010-06-02 15:01 ` Markus Armbruster
  2010-06-10 18:17 ` Blue Swirl
  0 siblings, 2 replies; 5+ messages in thread
From: Isaku Yamahata @ 2010-05-27  5:35 UTC (permalink / raw)
  To: qemu-devel

BusState::name is allocated in qbus_create_inplace().
So it should be freed by qbus_free().

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);
     }
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free()
  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
  2010-06-10 18:17 ` Blue Swirl
  1 sibling, 1 reply; 5+ messages in thread
From: Markus Armbruster @ 2010-06-02 15:01 UTC (permalink / raw)
  To: Isaku Yamahata; +Cc: qemu-devel

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 *.

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free()
  2010-06-02 15:01 ` Markus Armbruster
@ 2010-06-03  0:59   ` Isaku Yamahata
  2010-06-03  7:05     ` Markus Armbruster
  0 siblings, 1 reply; 5+ messages in thread
From: Isaku Yamahata @ 2010-06-03  0:59 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free()
  2010-06-03  0:59   ` Isaku Yamahata
@ 2010-06-03  7:05     ` Markus Armbruster
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2010-06-03  7:05 UTC (permalink / raw)
  To: Isaku Yamahata; +Cc: qemu-devel

Isaku Yamahata <yamahata@valinux.co.jp> writes:

> 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

You're right.  I keep suppressing all the silly trouble caused by const.
Sorry for the noise.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free()
  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-10 18:17 ` Blue Swirl
  1 sibling, 0 replies; 5+ messages in thread
From: Blue Swirl @ 2010-06-10 18:17 UTC (permalink / raw)
  To: Isaku Yamahata; +Cc: qemu-devel

Thanks, applied.

On Thu, May 27, 2010 at 5:35 AM, Isaku Yamahata <yamahata@valinux.co.jp> wrote:
> BusState::name is allocated in qbus_create_inplace().
> So it should be freed by qbus_free().
>
> 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);
>     }
> --
> 1.6.6.1
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-10 18:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2010-06-03  7:05     ` Markus Armbruster
2010-06-10 18:17 ` Blue Swirl

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).