diff mbox

Btrfs: ref-verify: Fix NULL vs IS_ERR() check in walk_down_tree()

Message ID 20171018073635.cajusx7hzkg4ghgc@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Oct. 18, 2017, 7:36 a.m. UTC
read_tree_block() returns error pointers, and never NULL and so I have
updated the error handling.

Fixes: 74739121b4c7 ("Btrfs: add a extent ref verify tool")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Sterba Oct. 18, 2017, 12:33 p.m. UTC | #1
On Wed, Oct 18, 2017 at 10:36:35AM +0300, Dan Carpenter wrote:
> read_tree_block() returns error pointers, and never NULL and so I have
> updated the error handling.
> 
> Fixes: 74739121b4c7 ("Btrfs: add a extent ref verify tool")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, I've folded the fix into the original commit and added credits.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c
index f65d78cf3c7e..34878699d363 100644
--- a/fs/btrfs/ref-verify.c
+++ b/fs/btrfs/ref-verify.c
@@ -584,7 +584,9 @@  static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
 			gen = btrfs_node_ptr_generation(path->nodes[level],
 							path->slots[level]);
 			eb = read_tree_block(fs_info, block_bytenr, gen);
-			if (!eb || !extent_buffer_uptodate(eb)) {
+			if (IS_ERR(eb))
+				return PTR_ERR(eb);
+			if (!extent_buffer_uptodate(eb)) {
 				free_extent_buffer(eb);
 				return -EIO;
 			}