]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: scrub: put bio after errors in scrub_raid56_parity_stripe()
authorZilin Guan <zilin@seu.edu.cn>
Wed, 5 Nov 2025 03:53:21 +0000 (03:53 +0000)
committerDavid Sterba <dsterba@suse.com>
Wed, 5 Nov 2025 19:01:12 +0000 (20:01 +0100)
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")
CC: stable@vger.kernel.org # 6.6+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/scrub.c

index 651b11884f82b2907c6a6b9a8ab196a71c91c612..ba20d9286a340cb671fe94e5b2b43a33c50f0521 100644 (file)
@@ -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;
        }