[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/10] block/rbd: fix memory leak in qemu_rbd_co_create_opts()
From: |
Kevin Wolf |
Subject: |
[PULL 02/10] block/rbd: fix memory leak in qemu_rbd_co_create_opts() |
Date: |
Fri, 9 Apr 2021 18:15:40 +0200 |
From: Stefano Garzarella <sgarzare@redhat.com>
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>
Message-Id: <20210329150129.121182-3-sgarzare@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@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");
--
2.30.2
- [PULL 00/10] Block layer fixes for 6.0-rc3, Kevin Wolf, 2021/04/09
- [PULL 01/10] block/rbd: fix memory leak in qemu_rbd_connect(), Kevin Wolf, 2021/04/09
- [PULL 02/10] block/rbd: fix memory leak in qemu_rbd_co_create_opts(),
Kevin Wolf <=
- [PULL 04/10] iotests: add test for removing persistent bitmap from backing file, Kevin Wolf, 2021/04/09
- [PULL 06/10] hw/block/fdc: Fix 'fallback' property on sysbus floppy disk controllers, Kevin Wolf, 2021/04/09
- [PULL 03/10] iotests/qsd-jobs: Filter events in the first test, Kevin Wolf, 2021/04/09
- [PULL 05/10] iotests: Test mirror-top filter permissions, Kevin Wolf, 2021/04/09
- [PULL 08/10] mirror: Do not enter a paused job on completion, Kevin Wolf, 2021/04/09
- [PULL 09/10] job: Allow complete for jobs on standby, Kevin Wolf, 2021/04/09
- [PULL 10/10] test-blockjob: Test job_wait_unpaused(), Kevin Wolf, 2021/04/09
- [PULL 07/10] mirror: Move open_backing_file to exit_common, Kevin Wolf, 2021/04/09
- Re: [PULL 00/10] Block layer fixes for 6.0-rc3, Peter Maydell, 2021/04/10