From: Wang Shilong Date: Mon, 28 Sep 2020 02:27:12 +0000 (+0800) Subject: e2fsck: fix memory leaks with pfsck enabled X-Git-Tag: v1.47.0-wc1~40 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=216d529718627d5311f88b40dd5e810a7fb77cae;p=tools%2Fe2fsprogs.git e2fsck: fix memory leaks with pfsck enabled valgrind detected two memory leaks: 1) quota context is not released after merging. 2) @refcount_orig should be released E2fsprogs-commit: d9aa090f713ecf3393c4e68d951a03ccba4a7073 Change-Id: I8b8379505524d25b5c18a0d67bb4dd8ede3494ef Signed-off-by: Wang Shilong Reviewed-by: Andreas Dilger Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c index 53af890..db0a505 100644 --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@ -106,6 +106,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; diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index f00d355..f0e0a36 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -3206,6 +3206,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.