From: Chao Yu <chao@kernel.org>
To: Yongpeng Yang <yangyongpeng1@oppo.com>, Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] f2fs: free victim_secmap when pinned_secmap allocation fails
Date: Mon, 22 Jul 2024 09:28:46 +0800 [thread overview]
Message-ID: <c81af94d-3b56-4169-b2eb-5d82623ab0af@kernel.org> (raw)
In-Reply-To: <20240720103349.3347764-1-yangyongpeng1@oppo.com>
On 2024/7/20 18:33, Yongpeng Yang wrote:
> In the init_victim_secmap function, if the allocation of
> dirty_i->pinned_secmap fails, dirty_i->victim_secmap is not
> freed, which can cause a memory leak.
>
> Signed-off-by: Yongpeng Yang <yangyongpeng1@oppo.com>
> ---
> fs/f2fs/segment.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 78c3198a6308..1e784ea3dbb4 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -4971,8 +4971,10 @@ static int init_victim_secmap(struct f2fs_sb_info *sbi)
> return -ENOMEM;
>
> dirty_i->pinned_secmap = f2fs_kvzalloc(sbi, bitmap_size, GFP_KERNEL);
> - if (!dirty_i->pinned_secmap)
> + if (!dirty_i->pinned_secmap) {
> + kvfree(dirty_i->victim_secmap);
Yongpeng,
In below path, it will release pinned_secmap/victim_secmap?
- f2fs_destroy_segment_manager
- destroy_victim_secmap
: kvfree(dirty_i->pinned_secmap);
: kvfree(dirty_i->victim_secmap);
Thanks,
> return -ENOMEM;
> + }
>
> dirty_i->pinned_secmap_cnt = 0;
> dirty_i->enable_pin_section = true;
next prev parent reply other threads:[~2024-07-22 1:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-20 10:33 Yongpeng Yang
2024-07-22 1:28 ` Chao Yu [this message]
2024-07-22 1:58 ` Yongpeng 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=c81af94d-3b56-4169-b2eb-5d82623ab0af@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=yangyongpeng1@oppo.com \
/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®