Skip to content

Commit ee49250

Browse files
GoodLuck612gregkh
authored andcommitted
btrfs: scrub: put bio after errors in scrub_raid56_parity_stripe()
commit 5fea61a upstream. 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: [email protected] # 6.6+ Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Zilin Guan <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 92f06ab commit ee49250

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/btrfs/scrub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
20912091
ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, full_stripe_start,
20922092
&length, &bioc, NULL, NULL);
20932093
if (ret < 0) {
2094+
bio_put(bio);
20942095
btrfs_put_bioc(bioc);
20952096
btrfs_bio_counter_dec(fs_info);
20962097
goto out;
@@ -2100,6 +2101,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
21002101
btrfs_put_bioc(bioc);
21012102
if (!rbio) {
21022103
ret = -ENOMEM;
2104+
bio_put(bio);
21032105
btrfs_bio_counter_dec(fs_info);
21042106
goto out;
21052107
}

0 commit comments

Comments
 (0)