Commit b6293c82 authored by Dan Carpenter's avatar Dan Carpenter Committed by David Sterba

btrfs: return error pointer from alloc_test_extent_buffer

Callers of alloc_test_extent_buffer have not correctly interpreted the
return value as error pointer, as alloc_test_extent_buffer should behave
as alloc_extent_buffer. The self-tests were unaffected but
btrfs_find_create_tree_block could call both functions and that would
cause problems up in the call chain.

Fixes: faa2dbf0 ("Btrfs: add sanity tests for new qgroup accounting code")
CC: stable@vger.kernel.org # 4.4+
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent cf93e15e
...@@ -5074,12 +5074,14 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -5074,12 +5074,14 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
return eb; return eb;
eb = alloc_dummy_extent_buffer(fs_info, start); eb = alloc_dummy_extent_buffer(fs_info, start);
if (!eb) if (!eb)
return NULL; return ERR_PTR(-ENOMEM);
eb->fs_info = fs_info; eb->fs_info = fs_info;
again: again:
ret = radix_tree_preload(GFP_NOFS); ret = radix_tree_preload(GFP_NOFS);
if (ret) if (ret) {
exists = ERR_PTR(ret);
goto free_eb; goto free_eb;
}
spin_lock(&fs_info->buffer_lock); spin_lock(&fs_info->buffer_lock);
ret = radix_tree_insert(&fs_info->buffer_radix, ret = radix_tree_insert(&fs_info->buffer_radix,
start >> PAGE_SHIFT, eb); start >> PAGE_SHIFT, eb);
......
...@@ -452,9 +452,9 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize, ...@@ -452,9 +452,9 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
root->fs_info->tree_root = root; root->fs_info->tree_root = root;
root->node = alloc_test_extent_buffer(root->fs_info, nodesize); root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
if (!root->node) { if (IS_ERR(root->node)) {
test_std_err(TEST_ALLOC_EXTENT_BUFFER); test_std_err(TEST_ALLOC_EXTENT_BUFFER);
ret = -ENOMEM; ret = PTR_ERR(root->node);
goto out; goto out;
} }
btrfs_set_header_level(root->node, 0); btrfs_set_header_level(root->node, 0);
......
...@@ -484,9 +484,9 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize) ...@@ -484,9 +484,9 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
* *cough*backref walking code*cough* * *cough*backref walking code*cough*
*/ */
root->node = alloc_test_extent_buffer(root->fs_info, nodesize); root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
if (!root->node) { if (IS_ERR(root->node)) {
test_err("couldn't allocate dummy buffer"); test_err("couldn't allocate dummy buffer");
ret = -ENOMEM; ret = PTR_ERR(root->node);
goto out; goto out;
} }
btrfs_set_header_level(root->node, 0); btrfs_set_header_level(root->node, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment