From: Qu Wenruo <wqu@suse.com>
To: Guanghui Yang <3497809730@qq.com>, Chris Mason <clm@fb.com>,
David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: free mapping node on duplicate reloc root insert
Date: Sun, 12 Jul 2026 08:15:40 +0930 [thread overview]
Message-ID: <07f63ae8-bdf2-4e6b-98d1-32dc3e083463@suse.com> (raw)
In-Reply-To: <tencent_39D68A519E8921206E77105E313354703C08@qq.com>
在 2026/7/12 01:11, Guanghui Yang 写道:
> __add_reloc_root() allocates a mapping_node before inserting it into
> rc->reloc_root_tree. If rb_simple_insert() finds an existing entry, it
> returns the existing rb_node and leaves the newly allocated node unlinked.
>
> The error path then returns -EEXIST without freeing the new node. Since
> the node was never inserted into reloc_root_tree, the later cleanup in
> put_reloc_control() cannot find it either.
>
> Free the newly allocated node before returning -EEXIST.
>
> The callers currently assert that -EEXIST should not happen, so this is a
> defensive cleanup for an unexpected duplicate insert path. If the path is
> ever reached, the local allocation should still be released.
>
> Signed-off-by: Guanghui Yang <3497809730@qq.com>
Missing fixes tag.
In commit ffd7b33944f4 ("btrfs: __add_reloc_root error push-up") there
is still the proper kfree(), but now it's not there.
There must be a commit removing that kfree().
> ---
> fs/btrfs/relocation.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index fb85bc8b345c..7e451e587726 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -588,6 +588,7 @@ static int __add_reloc_root(struct btrfs_root *root, struct reloc_control *rc)
> btrfs_err(fs_info,
> "Duplicate root found for start=%llu while inserting into relocation tree",
> node->bytenr);
> + kfree(node);
> return -EEXIST;
> }
>
next prev parent reply other threads:[~2026-07-11 22:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 15:41 [PATCH] btrfs: free mapping node on duplicate reloc root insert Guanghui Yang
2026-07-11 22:45 ` Qu Wenruo [this message]
2026-07-12 3:11 ` [PATCH v2] ext4: propagate errors from fast commit range replay Guanghui Yang
2026-07-12 3:19 ` Qu Wenruo
2026-07-12 3:27 ` Guanghui Yang
2026-07-12 3:17 ` [PATCH v2] btrfs: free mapping node on duplicate reloc root insert Guanghui Yang
2026-07-12 5:28 ` Qu Wenruo
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=07f63ae8-bdf2-4e6b-98d1-32dc3e083463@suse.com \
--to=wqu@suse.com \
--cc=3497809730@qq.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--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