From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Chuan Zheng <zhengchuan@huawei.com>
Cc: zhang.zhanghailiang@huawei.com, quintela@redhat.com,
linyilu@huawei.com, qemu-devel@nongnu.org, alex.chen@huawei.com,
fangying1@huawei.com, zhukeqian1@huawei.com
Subject: Re: [PATCH] migration: fix memory leak in qmp_migrate_set_parameters
Date: Thu, 27 Aug 2020 17:51:08 +0100 [thread overview]
Message-ID: <20200827165108.GA122424@work-vm> (raw)
In-Reply-To: <1594283305-105724-1-git-send-email-zhengchuan@huawei.com>
* Chuan Zheng (zhengchuan@huawei.com) wrote:
> From: Zheng Chuan <zhengchuan@huawei.com>
>
> "tmp.tls_hostname" and "tmp.tls_creds" allocated by migrate_params_test_apply()
> is forgot to free at the end of qmp_migrate_set_parameters(). Fix that.
>
> The leak stack:
> Direct leak of 2 byte(s) in 2 object(s) allocated from:
> #0 0xffffb597c20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
> #1 0xffffb52dcb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
> #2 0xffffb52f8143 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x74143)
> #3 0xaaaac52447fb in migrate_params_test_apply (/usr/src/debug/qemu-4.1.0/migration/migration.c:1377)
> #4 0xaaaac52fdca7 in qmp_migrate_set_parameters (/usr/src/debug/qemu-4.1.0/qapi/qapi-commands-migration.c:192)
> #5 0xaaaac551d543 in qmp_dispatch (/usr/src/debug/qemu-4.1.0/qapi/qmp-dispatch.c:165)
> #6 0xaaaac52a0a8f in qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:125)
> #7 0xaaaac52a1c7f in monitor_qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:214)
> #8 0xaaaac55cb0cf in aio_bh_call (/usr/src/debug/qemu-4.1.0/util/async.c:117)
> #9 0xaaaac55d4543 in aio_bh_poll (/usr/src/debug/qemu-4.1.0/util/aio-posix.c:459)
> #10 0xaaaac55cae0f in aio_dispatch (/usr/src/debug/qemu-4.1.0/util/async.c:268)
> #11 0xffffb52d6a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
> #12 0xaaaac55d1e3b(/usr/bin/qemu-kvm-4.1.0+0x1622e3b)
> #13 0xaaaac4e314bb(/usr/bin/qemu-kvm-4.1.0+0xe824bb)
> #14 0xaaaac47f45ef(/usr/bin/qemu-kvm-4.1.0+0x8455ef)
> #15 0xffffb4bfef3f in __libc_start_main (/usr/lib64/libc.so.6+0x23f3f)
> #16 0xaaaac47ffacb(/usr/bin/qemu-kvm-4.1.0+0x850acb)
>
> Direct leak of 2 byte(s) in 2 object(s) allocated from:
> #0 0xffffb597c20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
> #1 0xffffb52dcb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
> #2 0xffffb52f8143 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x74143)
> #3 0xaaaac5244893 in migrate_params_test_apply (/usr/src/debug/qemu-4.1.0/migration/migration.c:1382)
> #4 0xaaaac52fdca7 in qmp_migrate_set_parameters (/usr/src/debug/qemu-4.1.0/qapi/qapi-commands-migration.c:192)
> #5 0xaaaac551d543 in qmp_dispatch (/usr/src/debug/qemu-4.1.0/qapi/qmp-dispatch.c)
> #6 0xaaaac52a0a8f in qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:125)
> #7 0xaaaac52a1c7f in monitor_qmp_dispatch (/usr/src/debug/qemu-4.1.0/monitor/qmp.c:214)
> #8 0xaaaac55cb0cf in aio_bh_call (/usr/src/debug/qemu-4.1.0/util/async.c:117)
> #9 0xaaaac55d4543 in aio_bh_poll (/usr/src/debug/qemu-4.1.0/util/aio-posix.c:459)
> #10 0xaaaac55cae0f in in aio_dispatch (/usr/src/debug/qemu-4.1.0/util/async.c:268)
> #11 0xffffb52d6a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
> #12 0xaaaac55d1e3b(/usr/bin/qemu-kvm-4.1.0+0x1622e3b)
> #13 0xaaaac4e314bb(/usr/bin/qemu-kvm-4.1.0+0xe824bb)
> #14 0xaaaac47f45ef (/usr/bin/qemu-kvm-4.1.0+0x8455ef)
> #15 0xffffb4bfef3f in __libc_start_main (/usr/lib64/libc.so.6+0x23f3f)
> #16 0xaaaac47ffacb(/usr/bin/qemu-kvm-4.1.0+0x850acb)
>
> Signed-off-by: Chuan Zheng <zhengchuan@huawei.com>
> Reviewed-by: KeQian Zhu <zhukeqian1@huawei.com>
> Reviewed-by: HaiLiang <zhang.zhanghailiang@huawei.com@huawei.com>
Queued
> ---
> migration/migration.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/migration/migration.c b/migration/migration.c
> index 92e44e0..045180c 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -1342,12 +1342,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) {
> --
> 1.8.3.1
>
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2020-08-27 16:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 8:28 [PATCH] migration: fix memory leak in qmp_migrate_set_parameters Chuan Zheng
2020-07-09 9:40 ` Juan Quintela
2020-08-27 16:51 ` Dr. David Alan Gilbert [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-07-09 3:47 Chuan Zheng
2020-07-09 4:45 ` no-reply
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=20200827165108.GA122424@work-vm \
--to=dgilbert@redhat.com \
--cc=alex.chen@huawei.com \
--cc=fangying1@huawei.com \
--cc=linyilu@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=zhang.zhanghailiang@huawei.com \
--cc=zhengchuan@huawei.com \
--cc=zhukeqian1@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 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.