diff options
author | Zhao Lei <zhaolei@cn.fujitsu.com> | 2016-05-17 11:37:38 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-05-25 22:15:21 +0200 |
commit | f1fee6534dcfbf468a159789aa202db2bce8c200 (patch) | |
tree | 4149ed8954a0c344b354769d1c9bbed9a8e54114 /fs | |
parent | Btrfs: fix unexpected return value of fiemap (diff) | |
download | linux-f1fee6534dcfbf468a159789aa202db2bce8c200.tar.xz linux-f1fee6534dcfbf468a159789aa202db2bce8c200.zip |
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 <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/scrub.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index fa35cdc46494..ab3b9d604919 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -2181,7 +2181,7 @@ static void scrub_missing_raid56_pages(struct scrub_block *sblock) struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info; u64 length = sblock->page_count * PAGE_SIZE; u64 logical = sblock->pagev[0]->logical; - struct btrfs_bio *bbio; + struct btrfs_bio *bbio = NULL; struct bio *bio; struct btrfs_raid_bio *rbio; int ret; @@ -2982,6 +2982,7 @@ again: extent_len); mapped_length = extent_len; + bbio = NULL; ret = btrfs_map_block(fs_info, READ, extent_logical, &mapped_length, &bbio, 0); if (!ret) { |