All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, armbru@redhat.com,
	marcandre.lureau@redhat.com
Subject: Re: [Qemu-devel] [PATCH] ivshmem: fix memory backend leak
Date: Thu, 1 Nov 2018 16:22:45 +0100	[thread overview]
Message-ID: <20181101162245.3ce42fba@redhat.com> (raw)
In-Reply-To: <6cdf543e-77b2-ea7f-f0b8-f9da4384bd94@redhat.com>

On Thu, 1 Nov 2018 15:27:02 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:

> On 1/11/18 11:44, Igor Mammedov wrote:
> > object_new() returns a new backend with refcount == 1 and
> > then later object_property_add_child() increases refcount to 2
> > So when ivshmem is desroyed, the backend it has created isn't  
> 
>                       ^ "destroyed"
Thanks, fixed in v2

> 
> > destroyed along with it as children cleanup will bring
> > backend's refcount only to 1, which leaks backend including
> > resources it is using.
> > 
> > Drop the original reference from object_new() once backend
> > is attached to its parent.
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >   hw/misc/ivshmem.c | 1 +
> >   1 file changed, 1 insertion(+)
> > 
> > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> > index f88910e..ecfd10a 100644
> > --- a/hw/misc/ivshmem.c
> > +++ b/hw/misc/ivshmem.c
> > @@ -1279,6 +1279,7 @@ static void desugar_shm(IVShmemState *s)
> >       object_property_set_bool(obj, true, "share", &error_abort);
> >       object_property_add_child(OBJECT(s), "internal-shm-backend", obj,
> >                                 &error_abort);
> > +    object_unref(obj);
> >       user_creatable_complete(obj, &error_abort);
> >       s->hostmem = MEMORY_BACKEND(obj);
> >   }
> >   
> 

  reply	other threads:[~2018-11-01 15:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01 10:44 [Qemu-devel] [PATCH] ivshmem: fix memory backend leak Igor Mammedov
2018-11-01 11:02 ` Marc-André Lureau
2018-11-01 12:33   ` Igor Mammedov
2018-11-05 15:55     ` Markus Armbruster
2018-11-01 14:27 ` Philippe Mathieu-Daudé
2018-11-01 15:22   ` Igor Mammedov [this message]
2018-11-06 12:34 ` Paolo Bonzini

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=20181101162245.3ce42fba@redhat.com \
    --to=imammedo@redhat.com \
    --cc=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.