Re: [f2fs-dev] [PATCH] f2fs: fix ifolio leak in f2fs_move_inline_dirents

Chao Yu via Linux-f2fs-devel <[email protected]> Sun, 19 Jul 2026 15:21:27 +0800
Newsgroups net.sourceforge.lists.linux-f2fs-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 7/13/26 14:40, Guanghui Yang wrote:
> f2fs_move_inline_dirents() documents that the caller grabs ifolio, and
> that the function should release it on any error.
> 
> The f2fs_grab_cache_folio() failure path already drops ifolio, but the
> f2fs_reserve_block() failure path only drops the newly grabbed folio at
> the shared out label.  If f2fs_reserve_block() fails before clearing
> dn.inode_folio, the caller's ifolio reference is left behind.
> 
> Release ifolio on this error path when dn.inode_folio is still set.
> 
> Signed-off-by: Guanghui Yang <[email protected]>
> ---
>   fs/f2fs/inline.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
> index e2f7bedf1552..dea4ab957de8 100644
> --- a/fs/f2fs/inline.c
> +++ b/fs/f2fs/inline.c
> @@ -427,8 +427,11 @@ static int f2fs_move_inline_dirents(struct inode *dir, struct folio *ifolio,
>   
>   	set_new_dnode(&dn, dir, ifolio, NULL, 0);
>   	err = f2fs_reserve_block(&dn, 0);

f2fs_reserve_block() can handle the error case in itself?

Thanks,

> -	if (err)
> +	if (err) {
> +		if (dn.inode_folio)
> +			f2fs_folio_put(ifolio, true);
>   		goto out;
> +	}
>   
>   	if (unlikely(dn.data_blkaddr != NEW_ADDR)) {
>   		f2fs_put_dnode(&dn);
> 
> base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel