]> Pileus Git - ~andy/linux/commitdiff
Btrfs: do not continue if out of memory happens
authorWang Shilong <wangsl-fnst@cn.fujitsu.com>
Mon, 15 Apr 2013 10:26:38 +0000 (10:26 +0000)
committerJosef Bacik <jbacik@fusionio.com>
Mon, 6 May 2013 19:54:50 +0000 (15:54 -0400)
If out of memory happens, we should return -ENOMEM directly to the caller
rather than continue the work.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/backref.c

index 7f448b8325a1d1c2917d163cc85cf45547c08b9f..8623c74dfa0852d5f7f15c3aae02f5000b3516d8 100644 (file)
@@ -352,6 +352,8 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
                err = __resolve_indirect_ref(fs_info, search_commit_root,
                                             time_seq, ref, parents,
                                             extent_item_pos);
+               if (err == -ENOMEM)
+                       goto out;
                if (err)
                        continue;
 
@@ -367,7 +369,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
                        new_ref = kmalloc(sizeof(*new_ref), GFP_NOFS);
                        if (!new_ref) {
                                ret = -ENOMEM;
-                               break;
+                               goto out;
                        }
                        memcpy(new_ref, ref, sizeof(*ref));
                        new_ref->parent = node->val;
@@ -377,7 +379,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
                }
                ulist_reinit(parents);
        }
-
+out:
        ulist_free(parents);
        return ret;
 }