Commit 285190d9 authored by Tsutomu Itoh's avatar Tsutomu Itoh Committed by David Sterba

Btrfs: check return value of lookup_extent_mapping() correctly

This patch corrects error checking of lookup_extent_mapping().
Signed-off-by: default avatarTsutomu Itoh <t-itoh@jp.fujitsu.com>
parent 600a45e1
...@@ -588,6 +588,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -588,6 +588,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
page_offset(bio->bi_io_vec->bv_page), page_offset(bio->bi_io_vec->bv_page),
PAGE_CACHE_SIZE); PAGE_CACHE_SIZE);
read_unlock(&em_tree->lock); read_unlock(&em_tree->lock);
if (!em)
return -EIO;
compressed_len = em->block_len; compressed_len = em->block_len;
cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS); cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS);
......
...@@ -3308,7 +3308,7 @@ int try_release_extent_mapping(struct extent_map_tree *map, ...@@ -3308,7 +3308,7 @@ int try_release_extent_mapping(struct extent_map_tree *map,
len = end - start + 1; len = end - start + 1;
write_lock(&map->lock); write_lock(&map->lock);
em = lookup_extent_mapping(map, start, len); em = lookup_extent_mapping(map, start, len);
if (IS_ERR_OR_NULL(em)) { if (!em) {
write_unlock(&map->lock); write_unlock(&map->lock);
break; break;
} }
......
...@@ -1954,7 +1954,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, ...@@ -1954,7 +1954,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root,
em = lookup_extent_mapping(em_tree, chunk_offset, 1); em = lookup_extent_mapping(em_tree, chunk_offset, 1);
read_unlock(&em_tree->lock); read_unlock(&em_tree->lock);
BUG_ON(em->start > chunk_offset || BUG_ON(!em || em->start > chunk_offset ||
em->start + em->len < chunk_offset); em->start + em->len < chunk_offset);
map = (struct map_lookup *)em->bdev; map = (struct map_lookup *)em->bdev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment