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 v2] f2fs: fix ifolio leak in f2fs_get_new_data_folio
Date: Sun, 19 Jul 2026 15:14:43 +0800 [thread overview]
Message-ID: <bfb4dffb-e02a-480c-bb91-29cf97b48e66@kernel.org> (raw)
In-Reply-To: <tencent_90E4200062E0A9E878FE14F33C2142E0DC09@qq.com>
On 7/13/26 14:16, Guanghui Yang wrote:
> f2fs_get_new_data_folio() documents that ifolio is only set by
> make_empty_dir(), and that ifolio should be released by this function on
> any error.
>
> The allocation failure path already follows this rule, but the
> f2fs_reserve_block() failure path only drops the newly grabbed folio and
> returns the error. When make_empty_dir() passes a non-NULL ifolio, an
> early f2fs_reserve_block() failure can leave the extra inode folio
> reference held by the caller.
>
> Release ifolio on this error path if f2fs_reserve_block() has not already
> cleared dn.inode_folio.
>
> Signed-off-by: Guanghui Yang <3497809730@qq.com>
> ---
>
> Changes since v1:
> - Check dn.inode_folio before releasing ifolio to avoid a double put when
> f2fs_reserve_block() has already cleared the dnode.
>
> fs/f2fs/data.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index a765fda71536..6c573d392dac 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1477,6 +1477,8 @@ struct folio *f2fs_get_new_data_folio(struct inode *inode,
> err = f2fs_reserve_block(&dn, index);
> if (err) {
> f2fs_folio_put(folio, true);
> + if (dn.inode_folio)
> + f2fs_folio_put(ifolio, true);
No, caller will handle it.
> return ERR_PTR(err);
> }
> if (!ifolio)
>
> base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa
next prev parent reply other threads:[~2026-07-19 7:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260713055959.1865-1-3497809730@qq.com>
2026-07-13 6:16 ` [PATCH v2] f2fs: fix ifolio leak in f2fs_get_new_data_folio Guanghui Yang
2026-07-19 7:14 ` Chao Yu [this message]
2026-07-19 9:01 ` 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=bfb4dffb-e02a-480c-bb91-29cf97b48e66@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