mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Guanghui Yang <3497809730@qq.com>, Jaegeuk Kim <jaegeuk@kernel.org>
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] f2fs: fix ifolio leak in f2fs_move_inline_dirents
Date: Sun, 19 Jul 2026 15:21:27 +0800	[thread overview]
Message-ID: <c9081653-4295-4605-b543-ee84000b1ba4@kernel.org> (raw)
In-Reply-To: <tencent_FA4515CFD8902EB74708A91807AA001E3507@qq.com>

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 <3497809730@qq.com>
> ---
>   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


  reply	other threads:[~2026-07-19  7:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13  6:40 Guanghui Yang
2026-07-19  7:21 ` Chao Yu [this message]
2026-07-19  9:05   ` Guanghui Yang
2026-07-21  0:47     ` Chao Yu
2026-07-21  1:56       ` Guanghui Yang

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=c9081653-4295-4605-b543-ee84000b1ba4@kernel.org \
    --to=chao@kernel.org \
    --cc=3497809730@qq.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®