From: Baokun Li <libaokun1@huawei.com>
To: Zilin Guan <zilin@seu.edu.cn>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>,
<linux-ext4@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<jianhao.xu@seu.edu.cn>, <libaokun9@gmail.com>
Subject: Re: [PATCH] ext4: Fix memory leak in ext4_ext_shift_extents()
Date: Thu, 25 Dec 2025 17:10:17 +0800 [thread overview]
Message-ID: <7d0b0649-89db-4e04-a816-1c57dee31119@huawei.com> (raw)
In-Reply-To: <20251225084800.905701-1-zilin@seu.edu.cn>
On 2025-12-25 16:48, 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@seu.edu.cn>
Nice catch! The patch looks good so feel free to add:
Reviewed-by: Baokun Li <libaokun1@huawei.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)) {
next prev parent reply other threads:[~2025-12-25 9:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-25 8:48 [PATCH] ext4: Fix memory leak in ext4_ext_shift_extents() Zilin Guan
2025-12-25 9:10 ` Baokun Li [this message]
2025-12-25 11:09 ` Zhang Yi
2026-01-28 18:05 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7d0b0649-89db-4e04-a816-1c57dee31119@huawei.com \
--to=libaokun1@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=jianhao.xu@seu.edu.cn \
--cc=libaokun9@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=zilin@seu.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox