Skip to content

Commit bd7b525

Browse files
GoodLuck612gregkh
authored andcommitted
ext4: fix memory leak in ext4_ext_shift_extents()
commit ca81109 upstream. In ext4_ext_shift_extents(), if the extent is NULL in the while loop, the function returns immediately without releasing the path obtained via ext4_find_extent(), leading to a memory leak. Fix this by jumping to the out label to ensure the path is properly released. Fixes: a18ed35 ("ext4: always check ext4_ext_find_extent result") Signed-off-by: Zilin Guan <zilin@seu.edu.cn> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Baokun Li <libaokun1@huawei.com> Link: https://patch.msgid.link/20251225084800.905701-1-zilin@seu.edu.cn Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 31bf37c commit bd7b525

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/ext4/extents.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5414,7 +5414,8 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
54145414
if (!extent) {
54155415
EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
54165416
(unsigned long) *iterator);
5417-
return -EFSCORRUPTED;
5417+
ret = -EFSCORRUPTED;
5418+
goto out;
54185419
}
54195420
if (SHIFT == SHIFT_LEFT && *iterator >
54205421
le32_to_cpu(extent->ee_block)) {

0 commit comments

Comments
 (0)