Skip to content

Commit 5fea61a

Browse files
GoodLuck612kdave
authored andcommitted
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: 1009254 ("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>
1 parent bfe3d75 commit 5fea61a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/btrfs/scrub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,6 +2203,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
22032203
ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, full_stripe_start,
22042204
&length, &bioc, NULL, NULL);
22052205
if (ret < 0) {
2206+
bio_put(bio);
22062207
btrfs_put_bioc(bioc);
22072208
btrfs_bio_counter_dec(fs_info);
22082209
goto out;
@@ -2212,6 +2213,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
22122213
btrfs_put_bioc(bioc);
22132214
if (!rbio) {
22142215
ret = -ENOMEM;
2216+
bio_put(bio);
22152217
btrfs_bio_counter_dec(fs_info);
22162218
goto out;
22172219
}

0 commit comments

Comments
 (0)