From bc4d210783686a0b6728546576e4465912f99afc Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Mon, 6 Mar 2023 18:30:29 -0500 Subject: [PATCH] Fix memory leak in ztest This is tripping LeakSanitizer, which causes zloop test failures on pull requests. Reviewed-by: Tino Reichardt Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Closes #14583 --- cmd/ztest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/ztest.c b/cmd/ztest.c index 790835363f..fb9f83032e 100644 --- a/cmd/ztest.c +++ b/cmd/ztest.c @@ -4639,8 +4639,11 @@ ztest_dmu_object_alloc_free(ztest_ds_t *zd, uint64_t id) * Destroy the previous batch of objects, create a new batch, * and do some I/O on the new objects. */ - if (ztest_object_init(zd, od, size, B_TRUE) != 0) + if (ztest_object_init(zd, od, size, B_TRUE) != 0) { + zd->zd_od = NULL; + umem_free(od, size); return; + } while (ztest_random(4 * batchsize) != 0) ztest_io(zd, od[ztest_random(batchsize)].od_object,