]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ext4: fix memory leak in ext4_ext_shift_extents()
authorZilin Guan <zilin@seu.edu.cn>
Thu, 25 Dec 2025 08:48:00 +0000 (08:48 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2026 03:28:30 +0000 (22:28 -0500)
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: a18ed359bdddc ("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
fs/ext4/extents.c

index 27eb2c1df012832c3ed45329c68ce598cdc96317..e0295e0339b496640786cdeee5e38cd0e70d966b 100644 (file)
@@ -5406,7 +5406,8 @@ again:
                if (!extent) {
                        EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
                                         (unsigned long) *iterator);
-                       return -EFSCORRUPTED;
+                       ret = -EFSCORRUPTED;
+                       goto out;
                }
                if (SHIFT == SHIFT_LEFT && *iterator >
                    le32_to_cpu(extent->ee_block)) {