Btrfs: check return value of lookup_extent_mapping() correctly
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>
Thu, 16 Feb 2012 07:23:58 +0000 (16:23 +0900)
committerDavid Sterba <dsterba@suse.cz>
Thu, 16 Feb 2012 16:23:17 +0000 (17:23 +0100)
This patch corrects error checking of lookup_extent_mapping().

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
fs/btrfs/compression.c
fs/btrfs/extent_io.c
fs/btrfs/volumes.c

index 14f1c5a0b2d29f187955e9327cac6243715409f0..d02c27cd14c7073e05171150dc9b9d14bf78013c 100644 (file)
@@ -588,6 +588,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
                                   page_offset(bio->bi_io_vec->bv_page),
                                   PAGE_CACHE_SIZE);
        read_unlock(&em_tree->lock);
+       if (!em)
+               return -EIO;
 
        compressed_len = em->block_len;
        cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS);
index b05d35a7c0f1fa388b2511a968d6594740604122..8d6f55fbd28e8a0564d931c9b564a2cd9b8b90d4 100644 (file)
@@ -3308,7 +3308,7 @@ int try_release_extent_mapping(struct extent_map_tree *map,
                        len = end - start + 1;
                        write_lock(&map->lock);
                        em = lookup_extent_mapping(map, start, len);
-                       if (IS_ERR_OR_NULL(em)) {
+                       if (!em) {
                                write_unlock(&map->lock);
                                break;
                        }
index d8f282b5baa993b881cc6a91506d666825b34b96..cd040bf3fd87134bd36c76e40b29d7d0eab46b1d 100644 (file)
@@ -1954,7 +1954,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root,
        em = lookup_extent_mapping(em_tree, chunk_offset, 1);
        read_unlock(&em_tree->lock);
 
-       BUG_ON(em->start > chunk_offset ||
+       BUG_ON(!em || em->start > chunk_offset ||
               em->start + em->len < chunk_offset);
        map = (struct map_lookup *)em->bdev;