Skip to content

Commit

Permalink
Btrfs: check return value of kmalloc()
Browse files Browse the repository at this point in the history
The check on the return value of kmalloc() is added to some places.

Signed-off-by: Tsutomu Itoh <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
Tsutomu Itoh authored and chrismason-xx committed Apr 25, 2011
1 parent 43e817a commit 8d41371
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -8059,6 +8059,10 @@ static noinline int relocate_one_extent(struct btrfs_root *extent_root,
u64 group_start = group->key.objectid;
new_extents = kmalloc(sizeof(*new_extents),
GFP_NOFS);
if (!new_extents) {
ret = -ENOMEM;
goto out;
}
nr_extents = 1;
ret = get_new_locations(reloc_inode,
extent_key,
Expand Down
3 changes: 3 additions & 0 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
1, 0, NULL, GFP_NOFS);
while (start < end) {
async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS);
BUG_ON(!async_cow);
async_cow->inode = inode;
async_cow->root = root;
async_cow->locked_page = locked_page;
Expand Down Expand Up @@ -5001,6 +5002,8 @@ static noinline int uncompress_inline(struct btrfs_path *path,
inline_size = btrfs_file_extent_inline_item_len(leaf,
btrfs_item_nr(leaf, path->slots[0]));
tmp = kmalloc(inline_size, GFP_NOFS);
if (!tmp)
return -ENOMEM;
ptr = btrfs_file_extent_inline_start(item);

read_extent_buffer(leaf, tmp, ptr, inline_size);
Expand Down

0 comments on commit 8d41371

Please sign in to comment.