]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: ref-verify: fix IS_ERR() vs NULL check in btrfs_build_ref_tree()
authorAmit Dhingra <mechanicalamit@gmail.com>
Tue, 21 Oct 2025 12:07:20 +0000 (07:07 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2025 13:10:21 +0000 (14:10 +0100)
commit ada7d45b568abe4f1fd9c53d66e05fbea300674b upstream.

btrfs_extent_root()/btrfs_global_root() does not return error pointers,
it returns NULL on error.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/all/aNJfvxj0anEnk9Dm@stanley.mountain/
Fixes : ed4e6b5d644c ("btrfs: ref-verify: handle damaged extent root tree")
CC: stable@vger.kernel.org # 6.17+
Signed-off-by: Amit Dhingra <mechanicalamit@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ref-verify.c

index 9f1858b42c0e212abaf78b2cdf0c295e03aa9265..10d213a52b0509081f4e95f75b4fddcadb1434dc 100644 (file)
@@ -982,7 +982,7 @@ int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info)
 
        extent_root = btrfs_extent_root(fs_info, 0);
        /* If the extent tree is damaged we cannot ignore it (IGNOREBADROOTS). */
-       if (IS_ERR(extent_root)) {
+       if (!extent_root) {
                btrfs_warn(fs_info, "ref-verify: extent tree not available, disabling");
                btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
                return 0;