summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChunguang Xu <brookxu@tencent.com>2020-11-07 23:58:18 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-29 13:42:44 +0100
commitf4ce2117019fc4d80aef8cb8c159dd49330118a2 (patch)
treeb6d0898692349e56a390ff4c8ede54d7f4533871
parent1e367e94fca44f02aafb25f4fe9f31ff98a2aa64 (diff)
downloadlinux-stable-f4ce2117019fc4d80aef8cb8c159dd49330118a2.tar.gz
linux-stable-f4ce2117019fc4d80aef8cb8c159dd49330118a2.tar.bz2
linux-stable-f4ce2117019fc4d80aef8cb8c159dd49330118a2.zip
ext4: fix a memory leak of ext4_free_data
commit cca415537244f6102cbb09b5b90db6ae2c953bdd upstream. 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 small, since it only occurs if the file system is corrupted such that a block is claimed by more one inode and those inodes are deleted within a single jbd2 transaction. Signed-off-by: Chunguang Xu <brookxu@tencent.com> Link: https://lore.kernel.org/r/1604764698-4269-8-git-send-email-brookxu@tencent.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/ext4/mballoc.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 04fab14e630c..812e0ba25a08 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4646,6 +4646,7 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
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;
}
}