From 827be69ea6ca87db32e5f5462924cb20b8ed5b15 Mon Sep 17 00:00:00 2001 From: wsp1991 <18601959171@163.com> Date: Mon, 16 Mar 2020 19:45:29 +0800 Subject: [PATCH 1/4] block: fix two memleaks Signed-off-by: Pan Nengyuan --- ...2-do-free-crypto_opts-in-qcow2_close.patch | 29 ++++++++++++ qemu.spec | 2 + ...fix-memory-leak-in-throttle_group_se.patch | 44 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 block-qcow2-do-free-crypto_opts-in-qcow2_close.patch create mode 100644 throttle-groups-fix-memory-leak-in-throttle_group_se.patch 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 0000000..7276ea2 --- /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 6f399ac..0f291da 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 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 0000000..57a8a79 --- /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 + -- Gitee From bc70ec3247293181461803a4f93a0c36363bf926 Mon Sep 17 00:00:00 2001 From: wsp1991 <18601959171@163.com> Date: Mon, 16 Mar 2020 19:56:21 +0800 Subject: [PATCH 2/4] qemu.spec: add changelog Signed-off-by: Pan Nengyuan --- qemu.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qemu.spec b/qemu.spec index 0f291da..fbf6b2f 100644 --- a/qemu.spec +++ b/qemu.spec @@ -384,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 -- Gitee From f1133b553b66df27dc65484abc9aec46fb8bd6d1 Mon Sep 17 00:00:00 2001 From: wsp1991 <18601959171@163.com> Date: Mon, 16 Mar 2020 19:58:53 +0800 Subject: [PATCH 3/4] qemu.spec: fix changelog Signed-off-by: Pan Nengyuan --- qemu.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu.spec b/qemu.spec index fbf6b2f..8623c5b 100644 --- a/qemu.spec +++ b/qemu.spec @@ -384,7 +384,7 @@ getent passwd qemu >/dev/null || \ %endif %changelog -* Mon 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() -- Gitee From 09dd9268bde8f1c2349219b89fe03e2ea4f03bc7 Mon Sep 17 00:00:00 2001 From: wsp1991 <18601959171@163.com> Date: Mon, 16 Mar 2020 20:16:49 +0800 Subject: [PATCH 4/4] block: fix two memleaks Signed-off-by: Pan Nengyuan --- ...2-do-free-crypto_opts-in-qcow2_close.patch | 29 ++++++++++++ qemu.spec | 8 +++- ...fix-memory-leak-in-throttle_group_se.patch | 44 +++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 block-qcow2-do-free-crypto_opts-in-qcow2_close.patch create mode 100644 throttle-groups-fix-memory-leak-in-throttle_group_se.patch 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 0000000..7276ea2 --- /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 6f399ac..8623c5b 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 0000000..57a8a79 --- /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 + -- Gitee