qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Peter Krempa <pkrempa@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Subject: Re: [PATCH 1/4] migration: Prevent memleak by ...params_test_apply
Date: Wed, 1 Jul 2020 09:38:31 -0500	[thread overview]
Message-ID: <1e801600-db27-1625-f168-1b08396dc5b2@redhat.com> (raw)
In-Reply-To: <20200630084552.46362-2-mreitz@redhat.com>

On 6/30/20 3:45 AM, Max Reitz wrote:
> The created structure is not really a proper QAPI object, so we cannot
> and will not free its members.  Strings therein should therefore not be
> duplicated, or we will leak them.

This seems fragile to me; having to code QAPI usage differently 
depending on whether the containing struct was malloc'd or not (and 
therefore whether someone will call qapi_free_MigrateSetParameters or 
not) looks awkward to maintain.  We have 
visit_type_MigrateSetParameters_members, could that be used as a cleaner 
way to free all members of the struct without freeing the struct itself? 
  Should the QAPI generator start generating qapi_free_FOO_members to 
make such cleanup easier?

> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>   migration/migration.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 481a590f72..47c7da4e55 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -1336,12 +1336,12 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
>   
>       if (params->has_tls_creds) {
>           assert(params->tls_creds->type == QTYPE_QSTRING);
> -        dest->tls_creds = g_strdup(params->tls_creds->u.s);
> +        dest->tls_creds = params->tls_creds->u.s;
>       }
>   
>       if (params->has_tls_hostname) {
>           assert(params->tls_hostname->type == QTYPE_QSTRING);
> -        dest->tls_hostname = g_strdup(params->tls_hostname->u.s);
> +        dest->tls_hostname = params->tls_hostname->u.s;
>       }
>   
>       if (params->has_max_bandwidth) {
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



  parent reply	other threads:[~2020-07-01 14:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30  8:45 [PATCH 0/4] migration: Add block-bitmap-mapping parameter Max Reitz
2020-06-30  8:45 ` [PATCH 1/4] migration: Prevent memleak by ...params_test_apply Max Reitz
2020-06-30 10:28   ` Dr. David Alan Gilbert
2020-07-01 11:10   ` Vladimir Sementsov-Ogievskiy
2020-07-01 14:38   ` Eric Blake [this message]
2020-07-02  8:14     ` Max Reitz
2020-06-30  8:45 ` [PATCH 2/4] migration: Add block-bitmap-mapping parameter Max Reitz
2020-06-30 10:51   ` Dr. David Alan Gilbert
2020-07-01 10:34     ` Max Reitz
2020-07-02 11:22       ` Dr. David Alan Gilbert
2020-07-01 14:34   ` Vladimir Sementsov-Ogievskiy
2020-07-02  8:09     ` Max Reitz
2020-07-02  9:19       ` Vladimir Sementsov-Ogievskiy
2020-07-02  9:41         ` Max Reitz
2020-07-02 10:40           ` Vladimir Sementsov-Ogievskiy
2020-07-02 10:49           ` Vladimir Sementsov-Ogievskiy
2020-07-02 13:04           ` Vladimir Sementsov-Ogievskiy
2020-06-30  8:45 ` [PATCH 3/4] iotests.py: Add wait_for_runstate() Max Reitz
2020-06-30  8:45 ` [PATCH 4/4] iotests: Test node/bitmap aliases during migration Max Reitz
2020-07-02 11:24 ` [PATCH 0/4] migration: Add block-bitmap-mapping parameter Vladimir Sementsov-Ogievskiy

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=1e801600-db27-1625-f168-1b08396dc5b2@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=vsementsov@virtuozzo.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).