aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis de Bethencourt <luisbg@osg.samsung.com>2015-10-20 09:56:23 -0400
committerDavid Sterba <dsterba@suse.com>2015-10-21 12:29:50 -0400
commitddd664f4478a4aaf0ac67a4297e33f1992bc9be2 (patch)
treecf3484128d2fbcb804f0791174e1e99ea208b11b
parent0b8d8ce0297c4376d50318692e0aa53a3aaed90c (diff)
btrfs: reada: Fix returned errno code
reada is using -1 instead of the -ENOMEM defined macro to specify that a buffer allocation failed. Since the error number is propagated, the caller will get a -EPERM which is the wrong error condition. Also, updating the caller to return the exact value from reada_add_block. Smatch tool warning: reada_add_block() warn: returning -1 instead of -ENOMEM is sloppy Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/reada.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index 4645cd16d5ba..619f92963e27 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -569,7 +569,7 @@ static int reada_add_block(struct reada_control *rc, u64 logical,
569 rec = kzalloc(sizeof(*rec), GFP_NOFS); 569 rec = kzalloc(sizeof(*rec), GFP_NOFS);
570 if (!rec) { 570 if (!rec) {
571 reada_extent_put(root->fs_info, re); 571 reada_extent_put(root->fs_info, re);
572 return -1; 572 return -ENOMEM;
573 } 573 }
574 574
575 rec->rc = rc; 575 rec->rc = rc;
@@ -918,6 +918,7 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
918 u64 start; 918 u64 start;
919 u64 generation; 919 u64 generation;
920 int level; 920 int level;
921 int ret;
921 struct extent_buffer *node; 922 struct extent_buffer *node;
922 static struct btrfs_key max_key = { 923 static struct btrfs_key max_key = {
923 .objectid = (u64)-1, 924 .objectid = (u64)-1,
@@ -943,9 +944,10 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
943 generation = btrfs_header_generation(node); 944 generation = btrfs_header_generation(node);
944 free_extent_buffer(node); 945 free_extent_buffer(node);
945 946
946 if (reada_add_block(rc, start, &max_key, level, generation)) { 947 ret = reada_add_block(rc, start, &max_key, level, generation);
948 if (ret) {
947 kfree(rc); 949 kfree(rc);
948 return ERR_PTR(-ENOMEM); 950 return ERR_PTR(ret);
949 } 951 }
950 952
951 reada_start_machine(root->fs_info); 953 reada_start_machine(root->fs_info);