Commit c26a9203 authored by Tsutomu Itoh's avatar Tsutomu Itoh Committed by Chris Mason

Btrfs: check return value of alloc_extent_map()

I add the check on the return value of alloc_extent_map() to several places.
In addition, alloc_extent_map() returns only the address or NULL.
Therefore, check by IS_ERR() is unnecessary. So, I remove IS_ERR() checking.
Signed-off-by: default avatarTsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 67100f25
...@@ -6584,7 +6584,7 @@ static noinline int relocate_data_extent(struct inode *reloc_inode, ...@@ -6584,7 +6584,7 @@ static noinline int relocate_data_extent(struct inode *reloc_inode,
u64 end = start + extent_key->offset - 1; u64 end = start + extent_key->offset - 1;
em = alloc_extent_map(GFP_NOFS); em = alloc_extent_map(GFP_NOFS);
BUG_ON(!em || IS_ERR(em)); BUG_ON(!em);
em->start = start; em->start = start;
em->len = extent_key->offset; em->len = extent_key->offset;
......
...@@ -51,8 +51,8 @@ struct extent_map *alloc_extent_map(gfp_t mask) ...@@ -51,8 +51,8 @@ struct extent_map *alloc_extent_map(gfp_t mask)
{ {
struct extent_map *em; struct extent_map *em;
em = kmem_cache_alloc(extent_map_cache, mask); em = kmem_cache_alloc(extent_map_cache, mask);
if (!em || IS_ERR(em)) if (!em)
return em; return NULL;
em->in_tree = 0; em->in_tree = 0;
em->flags = 0; em->flags = 0;
em->compress_type = BTRFS_COMPRESS_NONE; em->compress_type = BTRFS_COMPRESS_NONE;
......
...@@ -185,6 +185,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, ...@@ -185,6 +185,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
split = alloc_extent_map(GFP_NOFS); split = alloc_extent_map(GFP_NOFS);
if (!split2) if (!split2)
split2 = alloc_extent_map(GFP_NOFS); split2 = alloc_extent_map(GFP_NOFS);
BUG_ON(!split || !split2);
write_lock(&em_tree->lock); write_lock(&em_tree->lock);
em = lookup_extent_mapping(em_tree, start, len); em = lookup_extent_mapping(em_tree, start, len);
......
...@@ -644,6 +644,7 @@ static noinline int submit_compressed_extents(struct inode *inode, ...@@ -644,6 +644,7 @@ static noinline int submit_compressed_extents(struct inode *inode,
async_extent->ram_size - 1, 0); async_extent->ram_size - 1, 0);
em = alloc_extent_map(GFP_NOFS); em = alloc_extent_map(GFP_NOFS);
BUG_ON(!em);
em->start = async_extent->start; em->start = async_extent->start;
em->len = async_extent->ram_size; em->len = async_extent->ram_size;
em->orig_start = em->start; em->orig_start = em->start;
...@@ -820,6 +821,7 @@ static noinline int cow_file_range(struct inode *inode, ...@@ -820,6 +821,7 @@ static noinline int cow_file_range(struct inode *inode,
BUG_ON(ret); BUG_ON(ret);
em = alloc_extent_map(GFP_NOFS); em = alloc_extent_map(GFP_NOFS);
BUG_ON(!em);
em->start = start; em->start = start;
em->orig_start = em->start; em->orig_start = em->start;
ram_size = ins.offset; ram_size = ins.offset;
...@@ -1169,6 +1171,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, ...@@ -1169,6 +1171,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
struct extent_map_tree *em_tree; struct extent_map_tree *em_tree;
em_tree = &BTRFS_I(inode)->extent_tree; em_tree = &BTRFS_I(inode)->extent_tree;
em = alloc_extent_map(GFP_NOFS); em = alloc_extent_map(GFP_NOFS);
BUG_ON(!em);
em->start = cur_offset; em->start = cur_offset;
em->orig_start = em->start; em->orig_start = em->start;
em->len = num_bytes; em->len = num_bytes;
......
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