From df053d67a9c07a9763a4c04468083644eb9aa234 Mon Sep 17 00:00:00 2001 From: Gvozden Neskovic Date: Thu, 28 Jul 2016 22:10:05 +0200 Subject: [PATCH] ztest: memory leaks reported by AddressSanitizer Leaks reported by using AddressSanitizer, GCC 6.1.0 Direct leak of 4097 byte(s) in 1 object(s) allocated from: #1 0x414f73 in process_options cmd/ztest/ztest.c:721 Direct leak of 5440 byte(s) in 17 object(s) allocated from: #1 0x41bfd5 in umem_alloc ../../lib/libspl/include/umem.h:88 #2 0x41bfd5 in ztest_zap_parallel cmd/ztest/ztest.c:4659 #3 0x4163a8 in ztest_execute cmd/ztest/ztest.c:5907 Signed-off-by: Gvozden Neskovic Signed-off-by: Brian Behlendorf Closes #4896 --- cmd/ztest/ztest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 2cc410f10c..852bf00a61 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -726,6 +726,7 @@ process_options(int argc, char **argv) } else { (void) strlcpy(zo->zo_dir, path, sizeof (zo->zo_dir)); + free(path); } break; case 'V': @@ -4702,8 +4703,10 @@ ztest_zap_parallel(ztest_ds_t *zd, uint64_t id) tx = dmu_tx_create(os); dmu_tx_hold_zap(tx, object, B_TRUE, NULL); txg = ztest_tx_assign(tx, TXG_MIGHTWAIT, FTAG); - if (txg == 0) + if (txg == 0) { + umem_free(od, sizeof (ztest_od_t)); return; + } bcopy(name, string_value, namelen); } else { tx = NULL;