public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Leo Martins <loemra.dev@gmail.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 1/2] btrfs: fix refcount leak in debug assertion
Date: Wed, 28 May 2025 07:46:26 +0930	[thread overview]
Message-ID: <aa0db803-55b9-422f-a2c4-977ed93b92eb@suse.com> (raw)
In-Reply-To: <1696139274b2bd4327c008ed6df6f58cb5a8569e.1748373059.git.loemra.dev@gmail.com>



在 2025/5/28 04:58, Leo Martins 写道:
> If the delayed_root is not empty we are increasing the number of
> references to a delayed_node without decreasing it, causing a leak.
> Fix by decrementing the delayed_node reference count.
> 
> Signed-off-by: Leo Martins <loemra.dev@gmail.com>
> ---
>   fs/btrfs/delayed-inode.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> index c7cc24a5dd5e..f4e47bfc603b 100644
> --- a/fs/btrfs/delayed-inode.c
> +++ b/fs/btrfs/delayed-inode.c
> @@ -1377,7 +1377,12 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,
>   
>   void btrfs_assert_delayed_root_empty(struct btrfs_fs_info *fs_info)
>   {
> -	WARN_ON(btrfs_first_delayed_node(fs_info->delayed_root));
> +	struct btrfs_delayed_node *node = btrfs_first_delayed_node(fs_info->delayed_root);
> +
> +	WARN_ON(node);
> +
> +	if (node)

Just like what Filipe has pointed out, one line "if (WARN_ON(node))" 
will be good enough.

Otherwise looks good to me.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu> +		refcount_dec(&node->refs);
>   }
>   
>   static bool could_end_wait(struct btrfs_delayed_root *delayed_root, int seq)


  parent reply	other threads:[~2025-05-27 22:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-27 19:28 [PATCH 0/2] delayed_node leak bug Leo Martins
2025-05-27 19:28 ` [PATCH 1/2] btrfs: fix refcount leak in debug assertion Leo Martins
2025-05-27 19:37   ` Filipe Manana
2025-05-27 22:16   ` Qu Wenruo [this message]
2025-05-27 19:28 ` [PATCH 2/2] btrfs: warn if leaking delayed_nodes Leo Martins
2025-05-27 19:38   ` Filipe Manana
2025-05-27 22:16   ` 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=aa0db803-55b9-422f-a2c4-977ed93b92eb@suse.com \
    --to=wqu@suse.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=loemra.dev@gmail.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