mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: dsterba@suse.com, josef@toxicpanda.com,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	naohiro.aota@wdc.com, stable@vger.kernel.org
Subject: Re: [PATCH] btrfs: Fix block group reference leak in btrfs_repair_one_zone()
Date: Fri, 18 Sep 2026 12:16:02 -0700	[thread overview]
Message-ID: <20260918191602.GC2956775@zen.localdomain> (raw)
In-Reply-To: <20260916171716.2087024-1-vulab@iscas.ac.cn>

On Wed, Sep 16, 2026 at 05:17:16PM +0000, Wentao Liang wrote:
> btrfs_repair_one_zone() hands the block group reference taken by
> btrfs_lookup_block_group() over to relocating_repair_kthread(), which
> drops it.  However the return value of kthread_run() is not checked,
> so when the kernel thread fails to spawn, nothing executes the put and
> the block group reference is leaked.
> 
> Check kthread_run() and drop the reference if the thread failed to
> start.
> 
> Fixes: f7ef5287a63d ("btrfs: zoned: relocate block group to repair IO failure in zoned filesystems")
> Cc: stable@vger.kernel.org

Reviewed-by: Boris Burkov <boris@bur.io>

> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  fs/btrfs/volumes.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index a88e68f90564..541bcd65a6f6 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -8770,6 +8770,7 @@ static int relocating_repair_kthread(void *data)
>  bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)
>  {
>  	struct btrfs_block_group *cache;
> +	struct task_struct *task;
>  
>  	if (!btrfs_is_zoned(fs_info))
>  		return false;
> @@ -8787,8 +8788,10 @@ bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical)
>  		return true;
>  	}
>  
> -	kthread_run(relocating_repair_kthread, cache,
> -		    "btrfs-relocating-repair");
> +	task = kthread_run(relocating_repair_kthread, cache,
> +			   "btrfs-relocating-repair");
> +	if (IS_ERR(task))
> +		btrfs_put_block_group(cache);
>  
>  	return true;
>  }
> -- 
> 2.34.1
> 

  reply	other threads:[~2026-09-18 19:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 17:17 Wentao Liang
2026-09-18 19:16 ` Boris Burkov [this message]
2026-09-21 12:32 ` David Sterba

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=20260918191602.GC2956775@zen.localdomain \
    --to=boris@bur.io \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=stable@vger.kernel.org \
    --cc=vulab@iscas.ac.cn \
    /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®