diff mbox series

[v2,8/8] ext4: fix a memory leak of ext4_free_data

Message ID 1603098158-30406-8-git-send-email-brookxu@tencent.com
State Superseded
Headers show
Series [v2,1/8] ext4: use ASSERT() to replace J_ASSERT() | expand

Commit Message

Chunguang Xu Oct. 19, 2020, 9:02 a.m. UTC
From: Chunguang Xu <brookxu@tencent.com>

When freeing metadata, we will create an ext4_free_data and
insert it into the pending free list. After the current
transaction is committed, the object will be freed.

ext4_mb_free_metadata() will check whether the area to be
freed overlaps with the pending free list. If true, return
directly. At this time, ext4_free_data is leaked. Fortunately,
the probability of this problem is relatively small, maybe we
should fix this problem.

Signed-off-by: Chunguang Xu <brookxu@tencent.com>
 fs/ext4/mballoc.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series


diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index e0a4265..aa6732a 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -5015,6 +5015,7 @@  static void ext4_try_merge_freed_extent(struct ext4_sb_info *sbi,
 				ext4_group_first_block_no(sb, group) +
 				EXT4_C2B(sbi, cluster),
 				"Block already on to-be-freed list");
+			kmem_cache_free(ext4_free_data_cachep, new_entry);
 			return 0;