btrfs: unify the error handling of btrfs_read_buffer()
[sfrench/cifs-2.6.git] / fs / btrfs / ctree.c
index 9b2d9cd4167632c71da879ae4e7f82a752dcd318..0eecf98d0abb85f226451a6b36bd6802806b6398 100644 (file)
@@ -1438,13 +1438,13 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
 
                /* now we're allowed to do a blocking uptodate check */
                ret = btrfs_read_buffer(tmp, gen, parent_level - 1, &first_key);
-               if (!ret) {
-                       *eb_ret = tmp;
-                       return 0;
+               if (ret) {
+                       free_extent_buffer(tmp);
+                       btrfs_release_path(p);
+                       return -EIO;
                }
-               free_extent_buffer(tmp);
-               btrfs_release_path(p);
-               return -EIO;
+               *eb_ret = tmp;
+               return 0;
        }
 
        /*