]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: fix memory leaks with pfsck enabled
authorWang Shilong <wshilong@ddn.com>
Mon, 28 Sep 2020 02:27:12 +0000 (10:27 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 25 Jan 2021 20:19:04 +0000 (15:19 -0500)
valgrind detected two memory leaks:

1) quota context is not released after merging.
2) @refcount_orig should be released

Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/e2fsck.c
e2fsck/pass1.c

index ca314778ce2aa098e27ff1512bbc40bff1892b94..b70aca21e9534d01d223cad1b0ad25ce1dfbbd0b 100644 (file)
@@ -102,6 +102,10 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx)
                ea_refcount_free(ctx->refcount_extra);
                ctx->refcount_extra = 0;
        }
+       if (ctx->refcount_orig) {
+               ea_refcount_free(ctx->refcount_orig);
+               ctx->refcount_orig = 0;
+       }
        if (ctx->ea_block_quota_blocks) {
                ea_refcount_free(ctx->ea_block_quota_blocks);
                ctx->ea_block_quota_blocks = 0;
index 4d9cd78a4b89ded5f30a90a4679d476abcf9bcea..0c8bd72f93d2de6492e0eb5d2c128bf28152aaab 100644 (file)
@@ -3111,6 +3111,7 @@ static int e2fsck_pass1_thread_join(e2fsck_t global_ctx, e2fsck_t thread_ctx)
                fclose(thread_ctx->problem_logf);
        }
 
+       quota_release_context(&thread_ctx->qctx);
        /*
         * @block_metadata_map and @block_dup_map are
         * shared, so we don't free them.