All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Qiang <liq3ea@gmail.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "Daniel P. Berrange" <berrange@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>, Li Qiang <liq3ea@163.com>,
	Qemu Developers <qemu-devel@nongnu.org>,
	Markus Armbruster <armbru@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] hmp: fix memory leak in qom_composition_compare()
Date: Wed, 15 Jul 2020 01:20:04 +0800	[thread overview]
Message-ID: <CAKXe6S+6L72ZfEQg55Uaj+h_-e90s060=USEsyos5m+8g9eRZA@mail.gmail.com> (raw)
In-Reply-To: <39e02324-eaa1-1aea-96d2-fba48483b6c0@redhat.com>

Philippe Mathieu-Daudé <philmd@redhat.com> 于2020年7月15日周三 上午12:47写道:
>
> On 7/14/20 5:11 PM, Li Qiang wrote:
> > While 'make chekc', I got following error:
> >
> > root@ubuntu:~/qemu# ./tests/qtest/device-introspect-test
> > /x86_64/device/introspect/list: OK
> > /x86_64/device/introspect/list-fields: OK
> > /x86_64/device/introspect/none:
> > =================================================================
> > ==53741==ERROR: LeakSanitizer: detected memory leaks
> >
> > Direct leak of 212 byte(s) in 20 object(s) allocated from:
> >     #0 0x7f3b6319cb40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
> >     #1 0x7f3b62805ab8 in g_malloc (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51ab8)
> >
> > SUMMARY: AddressSanitizer: 212 byte(s) leaked in 20 allocation(s).
> > tests/qtest/libqtest.c:166: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)
> > Aborted (core dumped)
> >
> > This is because the 'info qom-tree' path has a memory leak and qemu
> > exit 1. The leak is in 'qom_composition_compare'. This patch fixes this.
> >
> > Fixes: e8c9e65816f("qom: Make "info qom-tree" show children sorted")
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> > ---
> >  qom/qom-hmp-cmds.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
> > index 9ed8bb1c9f..3547d5ba4e 100644
> > --- a/qom/qom-hmp-cmds.c
> > +++ b/qom/qom-hmp-cmds.c
> > @@ -96,8 +96,10 @@ static void print_qom_composition(Monitor *mon, Object *obj, int indent);
> >
> >  static int qom_composition_compare(const void *a, const void *b, void *ignore)
> >  {
> > -    return g_strcmp0(a ? object_get_canonical_path_component(a) : NULL,
> > -                     b ? object_get_canonical_path_component(b) : NULL);
> > +    g_autofree char *t1 = a ? object_get_canonical_path_component(a) : NULL;
> > +    g_autofree char *t2 = b ? object_get_canonical_path_component(b) : NULL;
> > +
> > +    return g_strcmp0(t1, t2);
> >  }
> >
> >  static int insert_qom_composition_child(Object *obj, void *opaque)
> >
>
> Ah you won the race with Markus:
> https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg04740.html
>

Oh interesting, I just want to  begin to write the e1000e tx bh
discussed with Jason.
But found there are some memleak issue.

> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>


      reply	other threads:[~2020-07-14 17:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 15:11 [PATCH] hmp: fix memory leak in qom_composition_compare() Li Qiang
2020-07-14 16:47 ` Philippe Mathieu-Daudé
2020-07-14 17:20   ` Li Qiang [this message]

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='CAKXe6S+6L72ZfEQg55Uaj+h_-e90s060=USEsyos5m+8g9eRZA@mail.gmail.com' \
    --to=liq3ea@gmail.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=liq3ea@163.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.