Skip to content

Commit f1fee65

Browse files
zhaoleiddkdave
authored andcommitted
btrfs: scrub: Set bbio to NULL before calling btrfs_map_block
We usually call btrfs_put_bbio() when btrfs_map_block() failed, btrfs_put_bbio() works right whether bbio is a valid value, or NULL. But there is a exception, in some case, btrfs_map_block() will return fail without touching *bbio(keeping its original value), and if bbio was not initialized yet, invalid memory accessing will happened. Above case is in scrub_missing_raid56_pages(), and similar case in scrub_raid56_parity(). Signed-off-by: Zhao Lei <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 2d324f5 commit f1fee65

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/btrfs/scrub.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,7 @@ static void scrub_missing_raid56_pages(struct scrub_block *sblock)
21812181
struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info;
21822182
u64 length = sblock->page_count * PAGE_SIZE;
21832183
u64 logical = sblock->pagev[0]->logical;
2184-
struct btrfs_bio *bbio;
2184+
struct btrfs_bio *bbio = NULL;
21852185
struct bio *bio;
21862186
struct btrfs_raid_bio *rbio;
21872187
int ret;
@@ -2982,6 +2982,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
29822982
extent_len);
29832983

29842984
mapped_length = extent_len;
2985+
bbio = NULL;
29852986
ret = btrfs_map_block(fs_info, READ, extent_logical,
29862987
&mapped_length, &bbio, 0);
29872988
if (!ret) {

0 commit comments

Comments
 (0)