[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <74c06707-d062-44b6-a519-4520713c135d@huaweicloud.com>
Date: Thu, 25 Dec 2025 19:09:50 +0800
From: Zhang Yi <yi.zhang@...weicloud.com>
To: Zilin Guan <zilin@....edu.cn>, tytso@....edu
Cc: adilger.kernel@...ger.ca, linux-ext4@...r.kernel.org,
linux-kernel@...r.kernel.org, jianhao.xu@....edu.cn
Subject: Re: [PATCH] ext4: Fix memory leak in ext4_ext_shift_extents()
On 12/25/2025 4:48 PM, Zilin Guan wrote:
> 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@....edu.cn>
Looks good to me.
Reviewed-by: Zhang Yi <yi.zhang@...wei.com>
> ---
> fs/ext4/extents.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 2cf5759ba689..1d21943a09b0 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -5375,7 +5375,8 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
> 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)) {
Powered by blists - more mailing lists