Skip to content

Commit 6c569c9

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: 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 72b3b2e commit 6c569c9

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
@@ -2185,6 +2185,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
21852185
ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, full_stripe_start,
21862186
&length, &bioc, NULL, NULL);
21872187
if (ret < 0) {
2188+
bio_put(bio);
21882189
btrfs_put_bioc(bioc);
21892190
btrfs_bio_counter_dec(fs_info);
21902191
goto out;
@@ -2194,6 +2195,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
21942195
btrfs_put_bioc(bioc);
21952196
if (!rbio) {
21962197
ret = -ENOMEM;
2198+
bio_put(bio);
21972199
btrfs_bio_counter_dec(fs_info);
21982200
goto out;
21992201
}

0 commit comments

Comments
 (0)