]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: handle errors from btrfs_dec_ref() properly
authorJosef Bacik <josef@toxicpanda.com>
Tue, 7 May 2024 18:12:15 +0000 (14:12 -0400)
committerDavid Sterba <dsterba@suse.com>
Thu, 11 Jul 2024 13:33:25 +0000 (15:33 +0200)
In walk_up_proc() we BUG_ON(ret) from btrfs_dec_ref().  This is
incorrect, we have proper error handling here, return the error.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c

index d1c9158bf3e06d5de9fc45b96091346c5b78bb2d..ec3080664bb6b265e2c7192dfef73bb3a7cf0960 100644 (file)
@@ -5802,7 +5802,10 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans,
                                ret = btrfs_dec_ref(trans, root, eb, 1);
                        else
                                ret = btrfs_dec_ref(trans, root, eb, 0);
-                       BUG_ON(ret); /* -ENOMEM */
+                       if (ret) {
+                               btrfs_abort_transaction(trans, ret);
+                               return ret;
+                       }
                        if (is_fstree(btrfs_root_id(root))) {
                                ret = btrfs_qgroup_trace_leaf_items(trans, eb);
                                if (ret) {