[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/13] qom-qmp-cmds: fix two memleaks in qmp_object_add
From: |
Kevin Wolf |
Subject: |
[PULL 01/13] qom-qmp-cmds: fix two memleaks in qmp_object_add |
Date: |
Wed, 11 Mar 2020 16:42:06 +0100 |
From: Pan Nengyuan <address@hidden>
'type/id' forgot to free in qmp_object_add, this patch fix that.
The leak stack:
Direct leak of 84 byte(s) in 6 object(s) allocated from:
#0 0x7fe2a5ebf768 in __interceptor_malloc (/lib64/libasan.so.5+0xef768)
#1 0x7fe2a5044445 in g_malloc (/lib64/libglib-2.0.so.0+0x52445)
#2 0x7fe2a505dd92 in g_strdup (/lib64/libglib-2.0.so.0+0x6bd92)
#3 0x56344954e692 in qmp_object_add
/mnt/sdb/qemu-new/qemu_test/qemu/qom/qom-qmp-cmds.c:258
#4 0x563449960f5a in do_qmp_dispatch
/mnt/sdb/qemu-new/qemu_test/qemu/qapi/qmp-dispatch.c:132
#5 0x563449960f5a in qmp_dispatch
/mnt/sdb/qemu-new/qemu_test/qemu/qapi/qmp-dispatch.c:175
#6 0x563449498a30 in monitor_qmp_dispatch
/mnt/sdb/qemu-new/qemu_test/qemu/monitor/qmp.c:145
#7 0x56344949a64f in monitor_qmp_bh_dispatcher
/mnt/sdb/qemu-new/qemu_test/qemu/monitor/qmp.c:234
#8 0x563449a92a3a in aio_bh_call
/mnt/sdb/qemu-new/qemu_test/qemu/util/async.c:136
Direct leak of 54 byte(s) in 6 object(s) allocated from:
#0 0x7fe2a5ebf768 in __interceptor_malloc (/lib64/libasan.so.5+0xef768)
#1 0x7fe2a5044445 in g_malloc (/lib64/libglib-2.0.so.0+0x52445)
#2 0x7fe2a505dd92 in g_strdup (/lib64/libglib-2.0.so.0+0x6bd92)
#3 0x56344954e6c4 in qmp_object_add
/mnt/sdb/qemu-new/qemu_test/qemu/qom/qom-qmp-cmds.c:267
#4 0x563449960f5a in do_qmp_dispatch
/mnt/sdb/qemu-new/qemu_test/qemu/qapi/qmp-dispatch.c:132
#5 0x563449960f5a in qmp_dispatch
/mnt/sdb/qemu-new/qemu_test/qemu/qapi/qmp-dispatch.c:175
#6 0x563449498a30 in monitor_qmp_dispatch
/mnt/sdb/qemu-new/qemu_test/qemu/monitor/qmp.c:145
#7 0x56344949a64f in monitor_qmp_bh_dispatcher
/mnt/sdb/qemu-new/qemu_test/qemu/monitor/qmp.c:234
#8 0x563449a92a3a in aio_bh_call
/mnt/sdb/qemu-new/qemu_test/qemu/util/async.c:136
Fixes: 5f07c4d60d091320186e7b0edaf9ed2cc16b2d1e
Reported-by: Euler Robot <address@hidden>
Signed-off-by: Pan Nengyuan <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
Acked-by: Igor Mammedov <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qom/qom-qmp-cmds.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 49db926fcc..435193b036 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -247,26 +247,22 @@ void qmp_object_add(QDict *qdict, QObject **ret_data,
Error **errp)
QDict *pdict;
Visitor *v;
Object *obj;
- const char *type;
- const char *id;
+ g_autofree char *type = NULL;
+ g_autofree char *id = NULL;
- type = qdict_get_try_str(qdict, "qom-type");
+ type = g_strdup(qdict_get_try_str(qdict, "qom-type"));
if (!type) {
error_setg(errp, QERR_MISSING_PARAMETER, "qom-type");
return;
- } else {
- type = g_strdup(type);
- qdict_del(qdict, "qom-type");
}
+ qdict_del(qdict, "qom-type");
- id = qdict_get_try_str(qdict, "id");
+ id = g_strdup(qdict_get_try_str(qdict, "id"));
if (!id) {
error_setg(errp, QERR_MISSING_PARAMETER, "id");
return;
- } else {
- id = g_strdup(id);
- qdict_del(qdict, "id");
}
+ qdict_del(qdict, "id");
props = qdict_get(qdict, "props");
if (props) {
--
2.20.1
- [PULL 00/13] Block layer patches, Kevin Wolf, 2020/03/11
- [PULL 01/13] qom-qmp-cmds: fix two memleaks in qmp_object_add,
Kevin Wolf <=
- [PULL 03/13] block: Relax restrictions for blockdev-snapshot, Kevin Wolf, 2020/03/11
- [PULL 04/13] iotests: Fix run_job() with use_log=False, Kevin Wolf, 2020/03/11
- [PULL 05/13] iotests: Test mirror with temporarily disabled target backing file, Kevin Wolf, 2020/03/11
- [PULL 06/13] block: Fix cross-AioContext blockdev-snapshot, Kevin Wolf, 2020/03/11
- [PULL 07/13] iotests: Add iothread cases to 155, Kevin Wolf, 2020/03/11
- [PULL 02/13] block: Make bdrv_get_cumulative_perm() public, Kevin Wolf, 2020/03/11
- [PULL 08/13] qapi: Add '@allow-write-only-overlay' feature for 'blockdev-snapshot', Kevin Wolf, 2020/03/11
- [PULL 09/13] tests/qemu-iotests: Fix socket_scm_helper build path, Kevin Wolf, 2020/03/11
- [PULL 11/13] block.c: adding bdrv_co_delete_file, Kevin Wolf, 2020/03/11
- [PULL 12/13] crypto.c: cleanup created file when block_crypto_co_create_opts_luks fails, Kevin Wolf, 2020/03/11