diff options
author | Yoshinori Sano <yoshinori.sano@gmail.com> | 2011-02-15 07:01:42 -0500 |
---|---|---|
committer | root <Chris Mason chris.mason@oracle.com> | 2011-03-28 05:37:49 -0400 |
commit | dac97e516c617f9c797f64b0224050b70aea30c7 (patch) | |
tree | c5c7e7a40e649ee9beb9014b284d3a6e66fb94f2 /fs/btrfs/extent-tree.c | |
parent | c622ae6085d0c6ad834213bbf1477eb311359078 (diff) |
Btrfs: fix uncheck memory allocations
To make Btrfs code more robust, several return value checks where memory
allocation can fail are introduced. I use BUG_ON where I don't know how
to handle the error properly, which increases the number of using the
notorious BUG_ON, though.
Signed-off-by: Yoshinori Sano <yoshinori.sano@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 1efeda3b2f6f..cd0b69f57375 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -6978,6 +6978,10 @@ static noinline int get_new_locations(struct inode *reloc_inode, | |||
6978 | struct disk_extent *old = exts; | 6978 | struct disk_extent *old = exts; |
6979 | max *= 2; | 6979 | max *= 2; |
6980 | exts = kzalloc(sizeof(*exts) * max, GFP_NOFS); | 6980 | exts = kzalloc(sizeof(*exts) * max, GFP_NOFS); |
6981 | if (!exts) { | ||
6982 | ret = -ENOMEM; | ||
6983 | goto out; | ||
6984 | } | ||
6981 | memcpy(exts, old, sizeof(*exts) * nr); | 6985 | memcpy(exts, old, sizeof(*exts) * nr); |
6982 | if (old != *extents) | 6986 | if (old != *extents) |
6983 | kfree(old); | 6987 | kfree(old); |