Btrfs: return ENOMEM rather than use BUG_ON when btrfs_alloc_path fails
authorWang Shilong <wangsl-fnst@cn.fujitsu.com>
Wed, 27 Feb 2013 11:20:56 +0000 (11:20 +0000)
committerJosef Bacik <jbacik@fusionio.com>
Fri, 1 Mar 2013 15:13:04 +0000 (10:13 -0500)
Return ENOMEM rather trigger BUG_ON, fix it.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Reviewed-by: Zach Brown <zab@redhat.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/qgroup.c

index f011d9b8ffb1fbe66715fc2dd281434f8d716c4f..69fa487e29ce4368d779c90faefcca8fd3cef07b 100644 (file)
@@ -620,7 +620,9 @@ static int update_qgroup_limit_item(struct btrfs_trans_handle *trans,
        key.offset = qgroupid;
 
        path = btrfs_alloc_path();
-       BUG_ON(!path);
+       if (!path)
+               return -ENOMEM;
+
        ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
        if (ret > 0)
                ret = -ENOENT;
@@ -661,7 +663,9 @@ static int update_qgroup_info_item(struct btrfs_trans_handle *trans,
        key.offset = qgroup->qgroupid;
 
        path = btrfs_alloc_path();
-       BUG_ON(!path);
+       if (!path)
+               return -ENOMEM;
+
        ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
        if (ret > 0)
                ret = -ENOENT;
@@ -702,7 +706,9 @@ static int update_qgroup_status_item(struct btrfs_trans_handle *trans,
        key.offset = 0;
 
        path = btrfs_alloc_path();
-       BUG_ON(!path);
+       if (!path)
+               return -ENOMEM;
+
        ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
        if (ret > 0)
                ret = -ENOENT;