diff --git a/block-qcow2-do-free-crypto_opts-in-qcow2_close.patch b/block-qcow2-do-free-crypto_opts-in-qcow2_close.patch new file mode 100644 index 0000000000000000000000000000000000000000..7276ea21287207a1035b07687137606cbc14493f --- /dev/null +++ b/block-qcow2-do-free-crypto_opts-in-qcow2_close.patch @@ -0,0 +1,29 @@ +From 142bbde19233d10490605e15f49c398de22cafb0 Mon Sep 17 00:00:00 2001 +From: Pan Nengyuan +Date: Mon, 16 Mar 2020 19:39:41 +0800 +Subject: [PATCH 2/2] block/qcow2: do free crypto_opts in qcow2_close() + +'crypto_opts' forgot to free in qcow2_close(), this patch fix that. + +Reported-by: Euler Robot +Signed-off-by: Pan Nengyuan +(cherry picked from commit 4aebf0f0da4a57204f568deed14661cb37b4ac30) +--- + block/qcow2.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/block/qcow2.c b/block/qcow2.c +index 5fb115a..99dfe4a 100644 +--- a/block/qcow2.c ++++ b/block/qcow2.c +@@ -2325,6 +2325,7 @@ static void qcow2_close(BlockDriverState *bs) + + qcrypto_block_free(s->crypto); + s->crypto = NULL; ++ qapi_free_QCryptoBlockOpenOptions(s->crypto_opts); + + g_free(s->unknown_header_fields); + cleanup_unknown_header_ext(bs); +-- +1.8.3.1 + diff --git a/qemu.spec b/qemu.spec index 6f399ac201660495c554594c424aff73cec1e726..8623c5b4fb3fdb2d467a96bf509e2522fe354bc4 100644 --- a/qemu.spec +++ b/qemu.spec @@ -49,6 +49,8 @@ Patch0036: slirp-use-correct-size-while-emulating-commands.patch Patch0037: tcp_emu-fix-unsafe-snprintf-usages.patch Patch0038: block-iscsi-use-MIN-between-mx_sb_len-and-sb_len_wr.patch Patch0039: monitor-fix-memory-leak-in-monitor_fdset_dup_fd_find.patch +Patch0040: throttle-groups-fix-memory-leak-in-throttle_group_se.patch +Patch0041: block-qcow2-do-free-crypto_opts-in-qcow2_close.patch BuildRequires: flex BuildRequires: bison @@ -382,7 +384,11 @@ getent passwd qemu >/dev/null || \ %endif %changelog -* Thu Mar 16 2020 Huawei Technologies Co., Ltd. +* Mon Mar 16 2020 Huawei Technologies Co., Ltd. +- throttle-groups: fix memory leak in throttle_group_set_limit +- block/qcow2: do free crypto_opts in qcow2_close() + +* Mon Mar 16 2020 Huawei Technologies Co., Ltd. - moniter: fix memleak in monitor_fdset_dup_fd_find_remove - block/iscsi: use MIN() between mx_sb_len and sb_len_wr diff --git a/throttle-groups-fix-memory-leak-in-throttle_group_se.patch b/throttle-groups-fix-memory-leak-in-throttle_group_se.patch new file mode 100644 index 0000000000000000000000000000000000000000..57a8a79632b9a5877c5beec5b3e36837f2b45adc --- /dev/null +++ b/throttle-groups-fix-memory-leak-in-throttle_group_se.patch @@ -0,0 +1,44 @@ +From 4aa41f16244e9f9899832c7bfb1b250b460275ea Mon Sep 17 00:00:00 2001 +From: Pan Nengyuan +Date: Mon, 16 Mar 2020 19:28:23 +0800 +Subject: [PATCH 1/2] throttle-groups: fix memory leak in + throttle_group_set_limit + +This avoid a memory leak when qom-set is called to set throttle_group +limits, here is an easy way to reproduce: + +1. run qemu-iotests as follow and check the result with asan: + ./check -qcow2 184 + +Reported-by: Euler Robot +Signed-off-by: Pan Nengyuan +(cherry picked from commit 88be15a9e19c5130ecef07f2d01f7030bdf44051) +--- + block/throttle-groups.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/block/throttle-groups.c b/block/throttle-groups.c +index a5a2037..fd91fde 100644 +--- a/block/throttle-groups.c ++++ b/block/throttle-groups.c +@@ -892,8 +892,7 @@ static void throttle_group_set_limits(Object *obj, Visitor *v, + { + ThrottleGroup *tg = THROTTLE_GROUP(obj); + ThrottleConfig cfg; +- ThrottleLimits arg = { 0 }; +- ThrottleLimits *argp = &arg; ++ ThrottleLimits *argp; + Error *local_err = NULL; + + visit_type_ThrottleLimits(v, name, &argp, &local_err); +@@ -911,6 +910,7 @@ static void throttle_group_set_limits(Object *obj, Visitor *v, + unlock: + qemu_mutex_unlock(&tg->lock); + ret: ++ qapi_free_ThrottleLimits(argp); + error_propagate(errp, local_err); + return; + } +-- +1.8.3.1 +