From: Qu Wenruo <wqu@suse.com>
To: Guangshuo Li <lgs201920130244@gmail.com>,
Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>,
Jiasheng Jiang <jiashengjiangcool@gmail.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH] btrfs: fix double free in create_space_info() error path
Date: Wed, 1 Apr 2026 15:04:41 +1030 [thread overview]
Message-ID: <aa8c074d-fdce-460f-a9b7-8644880eebb5@suse.com> (raw)
In-Reply-To: <20260401031339.1418417-1-lgs201920130244@gmail.com>
在 2026/4/1 13:43, Guangshuo Li 写道:
> When kobject_init_and_add() fails, btrfs_sysfs_add_space_info_type()
> calls kobject_put(&space_info->kobj).
>
> The kobject release callback space_info_release() frees space_info,
> but the current error path in create_space_info() then calls
> kfree(space_info) again, causing a double free.
Can you give an example call chain of where such space_info_release() is
triggered?
>
> Keep the direct kfree(space_info) for the earlier failure path, but
> after btrfs_sysfs_add_space_info_type() has called kobject_put(), let
> the kobject release callback handle the cleanup.
>
> Fixes: a11224a016d6d ("btrfs: fix memory leaks in create_space_info() error paths")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> fs/btrfs/space-info.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index 3f08e450f796..d7176eb2fcbf 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -311,7 +311,7 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags)
>
> ret = btrfs_sysfs_add_space_info_type(space_info);
> if (ret)
> - goto out_free;
> + return ret;
>
> list_add(&space_info->list, &info->space_info);
> if (flags & BTRFS_BLOCK_GROUP_DATA)
next prev parent reply other threads:[~2026-04-01 4:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 3:13 [PATCH] btrfs: fix double free in create_space_info() error path Guangshuo Li
2026-04-01 4:34 ` Qu Wenruo [this message]
2026-04-01 8:09 ` Guangshuo Li
2026-04-01 9:08 ` 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=aa8c074d-fdce-460f-a9b7-8644880eebb5@suse.com \
--to=wqu@suse.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=jiashengjiangcool@gmail.com \
--cc=lgs201920130244@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@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