From: Peter Xu <peterx@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Het Gala <het.gala@nutanix.com>,
qemu-devel@nongnu.org, prerna.saxena@nutanix.com,
quintela@redhat.com, berrange@redhat.com,
peter.maydell@linaro.org, farosas@suse.de
Subject: Re: [PATCH v4] migration: Plug memory leak with migration URIs
Date: Thu, 30 Nov 2023 14:16:44 -0500 [thread overview]
Message-ID: <ZWjfnIjec3udUZZ-@x1n> (raw)
In-Reply-To: <87il5j2io0.fsf@pond.sub.org>
On Thu, Nov 30, 2023 at 07:35:43PM +0100, Markus Armbruster wrote:
> Peter Xu <peterx@redhat.com> writes:
>
> > On Wed, Nov 29, 2023 at 08:43:01PM +0000, Het Gala wrote:
> >> migrate_uri_parse() allocates memory to 'channel' if the user
> >> opts for old syntax - uri, which is leaked because there is no
> >> code for freeing 'channel'.
> >> So, free channel to avoid memory leak in case where 'channels'
> >> is empty and uri parsing is required.
> >>
> >> Fixes: 5994024f ("migration: Implement MigrateChannelList to qmp migration flow")
> >> Signed-off-by: Het Gala <het.gala@nutanix.com>
> >> Suggested-by: Markus Armbruster <armbru@redhat.com>
> >
> > Reviewed-by: Peter Xu <peterx@redhat.com>
> >
> >> @@ -533,18 +533,18 @@ static void qemu_start_incoming_migration(const char *uri, bool has_channels,
> >> error_setg(errp, "Channel list has more than one entries");
> >> return;
> >> }
> >> - channel = channels->value;
> >> + addr = channels->value->addr;
> >> } else if (uri) {
> >> /* caller uses the old URI syntax */
> >> if (!migrate_uri_parse(uri, &channel, errp)) {
> >> return;
> >> }
> >> + addr = channel->addr;
> >> } else {
> >> error_setg(errp, "neither 'uri' or 'channels' argument are "
> >> "specified in 'migrate-incoming' qmp command ");
> >> return;
> >> }
> >> - addr = channel->addr;
> >
> > Why these "addr" lines need change? Won't that behave the same as before?
>
> In the first case, @channel is now null. If we left the assignment to
> @addr alone, it would crash. Clearer now?
Is it this one?
if (uri && has_channels) {
error_setg(errp, "'uri' and 'channels' arguments are mutually "
"exclusive; exactly one of the two should be present in "
"'migrate-incoming' qmp command ");
return;
}
It returns already?
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2023-11-30 19:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 20:43 [PATCH v4] migration: Plug memory leak with migration URIs Het Gala
2023-11-30 7:21 ` Markus Armbruster
2023-11-30 17:29 ` Peter Xu
2023-11-30 18:35 ` Markus Armbruster
2023-11-30 19:16 ` Peter Xu [this message]
2023-12-01 6:19 ` Markus Armbruster
2023-12-01 15:29 ` Peter Xu
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=ZWjfnIjec3udUZZ-@x1n \
--to=peterx@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=farosas@suse.de \
--cc=het.gala@nutanix.com \
--cc=peter.maydell@linaro.org \
--cc=prerna.saxena@nutanix.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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).