diff options
| author | Tsutomu Itoh <t-itoh@jp.fujitsu.com> | 2011-04-25 19:43:52 -0400 |
|---|---|---|
| committer | Chris Mason <chris.mason@oracle.com> | 2011-04-25 19:43:52 -0400 |
| commit | 8d413713ca744fa00cf4e05d4054d80727b84789 (patch) | |
| tree | df29b480d83806cd4e85508ac676eb69323ddc79 | |
| parent | 43e817a1fdda17f3357602ed7964c248c8c53ae0 (diff) | |
Btrfs: check return value of kmalloc()
The check on the return value of kmalloc() is added to some places.
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
| -rw-r--r-- | fs/btrfs/extent-tree.c | 4 | ||||
| -rw-r--r-- | fs/btrfs/inode.c | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 31f33ba56fe8..cd52f7f556ef 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
| @@ -8059,6 +8059,10 @@ static noinline int relocate_one_extent(struct btrfs_root *extent_root, | |||
| 8059 | u64 group_start = group->key.objectid; | 8059 | u64 group_start = group->key.objectid; |
| 8060 | new_extents = kmalloc(sizeof(*new_extents), | 8060 | new_extents = kmalloc(sizeof(*new_extents), |
| 8061 | GFP_NOFS); | 8061 | GFP_NOFS); |
| 8062 | if (!new_extents) { | ||
| 8063 | ret = -ENOMEM; | ||
| 8064 | goto out; | ||
| 8065 | } | ||
| 8062 | nr_extents = 1; | 8066 | nr_extents = 1; |
| 8063 | ret = get_new_locations(reloc_inode, | 8067 | ret = get_new_locations(reloc_inode, |
| 8064 | extent_key, | 8068 | extent_key, |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a4157cfdd533..c718d274a352 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -953,6 +953,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page, | |||
| 953 | 1, 0, NULL, GFP_NOFS); | 953 | 1, 0, NULL, GFP_NOFS); |
| 954 | while (start < end) { | 954 | while (start < end) { |
| 955 | async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS); | 955 | async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS); |
| 956 | BUG_ON(!async_cow); | ||
| 956 | async_cow->inode = inode; | 957 | async_cow->inode = inode; |
| 957 | async_cow->root = root; | 958 | async_cow->root = root; |
| 958 | async_cow->locked_page = locked_page; | 959 | async_cow->locked_page = locked_page; |
| @@ -5001,6 +5002,8 @@ static noinline int uncompress_inline(struct btrfs_path *path, | |||
| 5001 | inline_size = btrfs_file_extent_inline_item_len(leaf, | 5002 | inline_size = btrfs_file_extent_inline_item_len(leaf, |
| 5002 | btrfs_item_nr(leaf, path->slots[0])); | 5003 | btrfs_item_nr(leaf, path->slots[0])); |
| 5003 | tmp = kmalloc(inline_size, GFP_NOFS); | 5004 | tmp = kmalloc(inline_size, GFP_NOFS); |
| 5005 | if (!tmp) | ||
| 5006 | return -ENOMEM; | ||
| 5004 | ptr = btrfs_file_extent_inline_start(item); | 5007 | ptr = btrfs_file_extent_inline_start(item); |
| 5005 | 5008 | ||
| 5006 | read_extent_buffer(leaf, tmp, ptr, inline_size); | 5009 | read_extent_buffer(leaf, tmp, ptr, inline_size); |
