[RFCv1 62/72] e2fsck: fix memory leaks with pfsck enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wang Shilong <wshilong@xxxxxxx>

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@xxxxxxx>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx>
---
 e2fsck/e2fsck.c | 4 ++++
 e2fsck/pass1.c  | 1 +
 2 files changed, 5 insertions(+)

diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c
index 53af8905..db0a5059 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 ed4275c3..d745699d 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -3039,6 +3039,7 @@ static int e2fsck_pass1_thread_join(e2fsck_t global_ctx, e2fsck_t thread_ctx)
 
 	retval = e2fsck_pass1_merge_context(global_ctx, thread_ctx);
 
+	quota_release_context(&thread_ctx->qctx);
 	/*
 	 * @block_metadata_map and @block_dup_map are
 	 * shared, so we don't free them.
-- 
2.37.3




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux