mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Zilin Guan <zilin@seu.edu.cn>, clm@fb.com
Cc: dsterba@suse.com, linux-btrfs@vger.kernel.org,
	linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn
Subject: Re: [PATCH] btrfs: scrub: fix memory leak in scrub_raid56_parity_stripe()
Date: Wed, 5 Nov 2025 19:23:18 +1030	[thread overview]
Message-ID: <5e8aa994-a7aa-43f7-86b9-9dec69624167@gmx.com> (raw)
In-Reply-To: <20251105035321.1897952-1-zilin@seu.edu.cn>



在 2025/11/5 14:23, Zilin Guan 写道:
> scrub_raid56_parity_stripe() allocates a bio with bio_alloc(), but
> fails to release it on some error paths, leading to a potential
> memory leak.
> 
> Add the missing bio_put() calls to properly drop the bio reference
> in those error cases.
> 
> Fixes: 1009254bf22a3 ("btrfs: scrub: use scrub_stripe to implement RAID56 P/Q scrub")
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>

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

Merged into for-next branch.

Thanks,
Qu
> ---
>   fs/btrfs/scrub.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index 651b11884f82..ba20d9286a34 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -2203,6 +2203,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
>   	ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, full_stripe_start,
>   			      &length, &bioc, NULL, NULL);
>   	if (ret < 0) {
> +		bio_put(bio);
>   		btrfs_put_bioc(bioc);
>   		btrfs_bio_counter_dec(fs_info);
>   		goto out;
> @@ -2212,6 +2213,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
>   	btrfs_put_bioc(bioc);
>   	if (!rbio) {
>   		ret = -ENOMEM;
> +		bio_put(bio);
>   		btrfs_bio_counter_dec(fs_info);
>   		goto out;
>   	}


  reply	other threads:[~2025-11-05  8:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05  3:53 Zilin Guan
2025-11-05  8:53 ` Qu Wenruo [this message]
2025-11-05 10:26 ` Markus Elfring
2025-11-06  2:12   ` Qu Wenruo
2025-11-06  6:55     ` Markus Elfring
2025-11-06  7:02       ` Qu Wenruo
2025-11-06  7:19         ` Markus Elfring

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=5e8aa994-a7aa-43f7-86b9-9dec69624167@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zilin@seu.edu.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®