From: Igor Mammedov <imammedo@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: b.galvani@gmail.com, peter.maydell@linaro.org,
drjones@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] hw/arm/cubieboard: make sure SOC object isn't leaked
Date: Fri, 6 Mar 2020 11:48:38 +0100 [thread overview]
Message-ID: <20200306114838.27603031@redhat.com> (raw)
In-Reply-To: <aef518d0-d8e5-7972-0530-8f8a4c64f1e1@redhat.com>
On Fri, 6 Mar 2020 11:33:07 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> On 3/3/20 10:12 AM, Igor Mammedov wrote:
> > SOC object returned by object_new() is leaked in current code.
> > Set SOC parent explicitly to board and then unref to SOC object
> > to make sure that refererence returned by object_new() is taken
> > care of.
> >
> > The SOC object will be kept alive by its parent (machine) and
> > will be automatically freed when MachineState is destroyed.
> >
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > Reported-by: Andrew Jones <drjones@redhat.com>
> > ---
> > hw/arm/cubieboard.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
> > index 089f9a30c1..12f8ac798d 100644
> > --- a/hw/arm/cubieboard.c
> > +++ b/hw/arm/cubieboard.c
> > @@ -30,9 +30,14 @@ static struct arm_boot_info cubieboard_binfo = {
> >
> > static void cubieboard_init(MachineState *machine)
> > {
> > - AwA10State *a10 = AW_A10(object_new(TYPE_AW_A10));
> > + AwA10State *a10;
> > Error *err = NULL;
> >
>
> What about using object_new_with_props similarly to commit e4c81e3a451f?
I prefer explicit object_property_add_child() and would use
above only if there are list of properties to feed to it.
> a10 = AW_A10(object_new_with_props(TYPE_AW_A10, OBJECT(s), "soc",
> &err, NULL));
> if (err != NULL) {
> error_propagate(errp, err);
> return;
> }
>
> > + a10 = AW_A10(object_new(TYPE_AW_A10));
> > + object_property_add_child(OBJECT(machine), "soc", OBJECT(a10),
> > + &error_abort);
> > + object_unref(OBJECT(a10));
> > +
> > object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err);
> > if (err != NULL) {
> > error_reportf_err(err, "Couldn't set phy address: ");
> >
>
next prev parent reply other threads:[~2020-03-06 10:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 9:12 [PATCH] hw/arm/cubieboard: make sure SOC object isn't leaked Igor Mammedov
2020-03-05 20:07 ` Niek Linnenbank
2020-03-06 10:06 ` Igor Mammedov
2020-03-06 10:33 ` Philippe Mathieu-Daudé
2020-03-06 10:48 ` Igor Mammedov [this message]
2020-03-10 19:49 ` Niek Linnenbank
2020-03-12 12:01 ` Peter Maydell
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=20200306114838.27603031@redhat.com \
--to=imammedo@redhat.com \
--cc=b.galvani@gmail.com \
--cc=drjones@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--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).