Commit 5fea61aa authored by Zilin Guan's avatar Zilin Guan Committed by David Sterba
Browse files

btrfs: scrub: put bio after errors in scrub_raid56_parity_stripe()



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: 1009254b ("btrfs: scrub: use scrub_stripe to implement RAID56 P/Q scrub")
CC: stable@vger.kernel.org # 6.6+
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarZilin Guan <zilin@seu.edu.cn>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent bfe3d755
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
	}