From da51bd17e5c3af7679d4dbe89a27057e7fc92fe0 Mon Sep 17 00:00:00 2001 From: Chunwei Chen Date: Tue, 14 Nov 2023 12:59:02 -0800 Subject: [PATCH] Fix snap_obj_array memory leak in check_filesystem() Use goto out instead of return for early exit to make sure snap_obj_array is freed. Reviewed-by: Brian Behlendorf Signed-off-by: Chunwei Chen Closes #15516 --- module/zfs/spa_errlog.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module/zfs/spa_errlog.c b/module/zfs/spa_errlog.c index 5dd08f597..244b4d264 100644 --- a/module/zfs/spa_errlog.c +++ b/module/zfs/spa_errlog.c @@ -425,8 +425,10 @@ check_filesystem(spa_t *spa, uint64_t head_ds, zbookmark_err_phys_t *zep, dsl_dataset_rele_flags(ds, DS_HOLD_FLAG_DECRYPT, FTAG); } - if (zap_clone == 0 || aff_snap_count == 0) - return (0); + if (zap_clone == 0 || aff_snap_count == 0) { + error = 0; + goto out; + } /* Check clones. */ zap_cursor_t *zc;