qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: pannengyuan@huawei.com, lvivier@redhat.com, pbonzini@redhat.com
Cc: zhang.zhanghailiang@huawei.com, qemu-devel@nongnu.org
Subject: Re: [PATCH] vhost-user-test: fix a memory leak
Date: Wed, 11 Dec 2019 08:57:08 +0100	[thread overview]
Message-ID: <eb4d58d0-ac2e-e69d-0a04-87fd5fc14e6e@redhat.com> (raw)
In-Reply-To: <1576025722-41720-1-git-send-email-pannengyuan@huawei.com>

 Hi!

On 11/12/2019 01.55, pannengyuan@huawei.com wrote:
[...]
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index 91ea373..54be931 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -717,6 +717,8 @@ static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)
>      guint64 size;
>  
>      if (!wait_for_fds(s)) {
> +        g_free(uri);
> +        test_server_free(dest);
>          return;
>      }

Well spotted. But I'd prefer to rather move the allocation of these
resources after the if-statement instead of doing the allocation at the
declaration of the variables already. Or maybe use a "goto out" and jump
to the end of the function instead? ... whatever you prefer, but
duplicating the "free" functions sounds like a cumbersome solution to me.

 Thanks,
  Thomas



  parent reply	other threads:[~2019-12-11  7:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-11  0:55 [PATCH] vhost-user-test: fix a memory leak pannengyuan
2019-12-11  7:48 ` Laurent Vivier
2019-12-12  1:11   ` Pan Nengyuan
2019-12-11  7:57 ` Thomas Huth [this message]
2019-12-11  8:18   ` Marc-André Lureau
2019-12-12  1:48     ` Pan Nengyuan
2019-12-12  1:41   ` Pan Nengyuan

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=eb4d58d0-ac2e-e69d-0a04-87fd5fc14e6e@redhat.com \
    --to=thuth@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pannengyuan@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhang.zhanghailiang@huawei.com \
    /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).