All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Peter Lieven <pl@kamp.de>,
	qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Florian Florensa <fflorensa@online.net>,
	Jason Dillaman <dillaman@redhat.com>
Subject: Re: [PATCH 2/2] block/rbd: fix memory leak in qemu_rbd_co_create_opts()
Date: Tue, 06 Apr 2021 10:23:04 +0200	[thread overview]
Message-ID: <87eefnddp3.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20210329150129.121182-3-sgarzare@redhat.com> (Stefano Garzarella's message of "Mon, 29 Mar 2021 17:01:29 +0200")

Stefano Garzarella <sgarzare@redhat.com> writes:

> When we allocate 'q_namespace', we forgot to set 'has_q_namespace'
> to true. This can cause several issues, including a memory leak,
> since qapi_free_BlockdevCreateOptions() does not deallocate that
> memory, as reported by valgrind:
>
>   13 bytes in 1 blocks are definitely lost in loss record 7 of 96
>      at 0x4839809: malloc (vg_replace_malloc.c:307)
>      by 0x48CEBB8: g_malloc (in /usr/lib64/libglib-2.0.so.0.6600.8)
>      by 0x48E3FE3: g_strdup (in /usr/lib64/libglib-2.0.so.0.6600.8)
>      by 0x180010: qemu_rbd_co_create_opts (rbd.c:446)
>      by 0x1AE72C: bdrv_create_co_entry (block.c:492)
>      by 0x241902: coroutine_trampoline (coroutine-ucontext.c:173)
>      by 0x57530AF: ??? (in /usr/lib64/libc-2.32.so)
>      by 0x1FFEFFFA6F: ???
>
> Fix setting 'has_q_namespace' to true when we allocate 'q_namespace'.
>
> Fixes: 19ae9ae014 ("block/rbd: Add support for ceph namespaces")
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
>  block/rbd.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/block/rbd.c b/block/rbd.c
> index 24cefcd0dc..f098a89c7b 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -444,6 +444,7 @@ static int coroutine_fn qemu_rbd_co_create_opts(BlockDriver *drv,
>      loc->user        = g_strdup(qdict_get_try_str(options, "user"));
>      loc->has_user    = !!loc->user;
>      loc->q_namespace = g_strdup(qdict_get_try_str(options, "namespace"));
> +    loc->has_q_namespace = !!loc->q_namespace;
>      loc->image       = g_strdup(qdict_get_try_str(options, "image"));
>      keypairs         = qdict_get_try_str(options, "=keyvalue-pairs");

Reviewed-by: Markus Armbruster <armbru@redhat.com>



  reply	other threads:[~2021-04-06  8:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 15:01 [PATCH 0/2] block/rbd: fix memory leaks Stefano Garzarella
2021-03-29 15:01 ` [PATCH 1/2] block/rbd: fix memory leak in qemu_rbd_connect() Stefano Garzarella
2021-04-06  8:22   ` Markus Armbruster
2021-04-08  7:49     ` Stefano Garzarella
2021-03-29 15:01 ` [PATCH 2/2] block/rbd: fix memory leak in qemu_rbd_co_create_opts() Stefano Garzarella
2021-04-06  8:23   ` Markus Armbruster [this message]
2021-04-06 17:06 ` [PATCH 0/2] block/rbd: fix memory leaks Max Reitz
2021-04-07  9:38   ` Markus Armbruster
2021-04-08  7:54     ` Stefano Garzarella
2021-04-07 13:31 ` Kevin Wolf

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=87eefnddp3.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=dillaman@redhat.com \
    --cc=fflorensa@online.net \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pl@kamp.de \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@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 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.