Skip to content

Commit 285190d

Browse files
Tsutomu Itohkdave
authored andcommitted
Btrfs: check return value of lookup_extent_mapping() correctly
This patch corrects error checking of lookup_extent_mapping(). Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
1 parent 600a45e commit 285190d

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎fs/btrfs/compression.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
588588
page_offset(bio->bi_io_vec->bv_page),
589589
PAGE_CACHE_SIZE);
590590
read_unlock(&em_tree->lock);
591+
if (!em)
592+
return -EIO;
591593

592594
compressed_len = em->block_len;
593595
cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS);

‎fs/btrfs/extent_io.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3308,7 +3308,7 @@ int try_release_extent_mapping(struct extent_map_tree *map,
33083308
len = end - start + 1;
33093309
write_lock(&map->lock);
33103310
em = lookup_extent_mapping(map, start, len);
3311-
if (IS_ERR_OR_NULL(em)) {
3311+
if (!em) {
33123312
write_unlock(&map->lock);
33133313
break;
33143314
}

‎fs/btrfs/volumes.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root,
19541954
em = lookup_extent_mapping(em_tree, chunk_offset, 1);
19551955
read_unlock(&em_tree->lock);
19561956

1957-
BUG_ON(em->start > chunk_offset ||
1957+
BUG_ON(!em || em->start > chunk_offset ||
19581958
em->start + em->len < chunk_offset);
19591959
map = (struct map_lookup *)em->bdev;
19601960

0 commit comments

Comments
 (0)