qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free()


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free()
Date: Thu, 03 Jun 2010 09:05:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Isaku Yamahata <address@hidden> writes:

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]