qemu-arm
[Top][All Lists]
Advanced

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

Re: [PATCH] hw/arm/cubieboard: make sure SOC object isn't leaked


From: Igor Mammedov
Subject: Re: [PATCH] hw/arm/cubieboard: make sure SOC object isn't leaked
Date: Fri, 6 Mar 2020 11:06:49 +0100

On Thu, 5 Mar 2020 21:07:08 +0100
Niek Linnenbank <address@hidden> wrote:

> Hi Igor,
> 
[...]

> > +    a10 = AW_A10(object_new(TYPE_AW_A10));
> > +    object_property_add_child(OBJECT(machine), "soc", OBJECT(a10),
> > +                              &error_abort);
> > +    object_unref(OBJECT(a10));
> >  
> 
> I see that there are a few machines which also do
> object_property_add_child() to add its
> SoC object to the machine, but they do not do the object_unref(). Can you
> explain why it is needed here?

object_new() returns object with ref == 1, and it's responsibility
of the caller to take care of it.
If caller won't track and call object_unref() eventually on returned pointer,
the object will leak.

(object_unref() destroys object when 'ref' reaches 0 )

> Or do the other machines still have a leak due to the missing
> object_unref()? Examples are:
>   hw/arm/sabrelite.c
>   hw/arm/mcimx7d-sabre.c
>   hw/arm/mcimx6ul-evk.c
> 
> Regards,
> Niek
> 
> 
> > +
> >      object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err);
> >      if (err != NULL) {
> >          error_reportf_err(err, "Couldn't set phy address: ");
> > --
> > 2.18.1
> >
> >
> >  
> 




reply via email to

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