diff options
author | Tsutomu Itoh <t-itoh@jp.fujitsu.com> | 2011-02-13 19:45:29 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-02-14 16:21:37 -0500 |
commit | c26a920373a983b52223eed5a13b97404d8b4158 (patch) | |
tree | a7f76fe1b0cecbc712f0b152ff537805f126b113 /fs/btrfs | |
parent | 67100f255dba284bcbb5ce795355dad1cff35658 (diff) |
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: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/extent-tree.c | 2 | ||||
-rw-r--r-- | fs/btrfs/extent_map.c | 4 | ||||
-rw-r--r-- | fs/btrfs/file.c | 1 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 3 |
4 files changed, 7 insertions, 3 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 565e22d77b1b..a7aaa10c5302 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -6584,7 +6584,7 @@ static noinline int relocate_data_extent(struct inode *reloc_inode, | |||
6584 | u64 end = start + extent_key->offset - 1; | 6584 | u64 end = start + extent_key->offset - 1; |
6585 | 6585 | ||
6586 | em = alloc_extent_map(GFP_NOFS); | 6586 | em = alloc_extent_map(GFP_NOFS); |
6587 | BUG_ON(!em || IS_ERR(em)); | 6587 | BUG_ON(!em); |
6588 | 6588 | ||
6589 | em->start = start; | 6589 | em->start = start; |
6590 | em->len = extent_key->offset; | 6590 | em->len = extent_key->offset; |
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c index b0e1fce12530..2b6c12e983b3 100644 --- a/fs/btrfs/extent_map.c +++ b/fs/btrfs/extent_map.c | |||
@@ -51,8 +51,8 @@ struct extent_map *alloc_extent_map(gfp_t mask) | |||
51 | { | 51 | { |
52 | struct extent_map *em; | 52 | struct extent_map *em; |
53 | em = kmem_cache_alloc(extent_map_cache, mask); | 53 | em = kmem_cache_alloc(extent_map_cache, mask); |
54 | if (!em || IS_ERR(em)) | 54 | if (!em) |
55 | return em; | 55 | return NULL; |
56 | em->in_tree = 0; | 56 | em->in_tree = 0; |
57 | em->flags = 0; | 57 | em->flags = 0; |
58 | em->compress_type = BTRFS_COMPRESS_NONE; | 58 | em->compress_type = BTRFS_COMPRESS_NONE; |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index b0ff34b96607..65338a1d14ad 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -185,6 +185,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, | |||
185 | split = alloc_extent_map(GFP_NOFS); | 185 | split = alloc_extent_map(GFP_NOFS); |
186 | if (!split2) | 186 | if (!split2) |
187 | split2 = alloc_extent_map(GFP_NOFS); | 187 | split2 = alloc_extent_map(GFP_NOFS); |
188 | BUG_ON(!split || !split2); | ||
188 | 189 | ||
189 | write_lock(&em_tree->lock); | 190 | write_lock(&em_tree->lock); |
190 | em = lookup_extent_mapping(em_tree, start, len); | 191 | em = lookup_extent_mapping(em_tree, start, len); |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index c9bc0afdbfc6..8d392ed73d57 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -644,6 +644,7 @@ retry: | |||
644 | async_extent->ram_size - 1, 0); | 644 | async_extent->ram_size - 1, 0); |
645 | 645 | ||
646 | em = alloc_extent_map(GFP_NOFS); | 646 | em = alloc_extent_map(GFP_NOFS); |
647 | BUG_ON(!em); | ||
647 | em->start = async_extent->start; | 648 | em->start = async_extent->start; |
648 | em->len = async_extent->ram_size; | 649 | em->len = async_extent->ram_size; |
649 | em->orig_start = em->start; | 650 | em->orig_start = em->start; |
@@ -820,6 +821,7 @@ static noinline int cow_file_range(struct inode *inode, | |||
820 | BUG_ON(ret); | 821 | BUG_ON(ret); |
821 | 822 | ||
822 | em = alloc_extent_map(GFP_NOFS); | 823 | em = alloc_extent_map(GFP_NOFS); |
824 | BUG_ON(!em); | ||
823 | em->start = start; | 825 | em->start = start; |
824 | em->orig_start = em->start; | 826 | em->orig_start = em->start; |
825 | ram_size = ins.offset; | 827 | ram_size = ins.offset; |
@@ -1169,6 +1171,7 @@ out_check: | |||
1169 | struct extent_map_tree *em_tree; | 1171 | struct extent_map_tree *em_tree; |
1170 | em_tree = &BTRFS_I(inode)->extent_tree; | 1172 | em_tree = &BTRFS_I(inode)->extent_tree; |
1171 | em = alloc_extent_map(GFP_NOFS); | 1173 | em = alloc_extent_map(GFP_NOFS); |
1174 | BUG_ON(!em); | ||
1172 | em->start = cur_offset; | 1175 | em->start = cur_offset; |
1173 | em->orig_start = em->start; | 1176 | em->orig_start = em->start; |
1174 | em->len = num_bytes; | 1177 | em->len = num_bytes; |