]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:31:01 +0000 (14:31 +0200)
commit 5eb178f373b4f16f3b42d55ff88fc94dd95b93b1 upstream.

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>
Signed-off-by: Jianqi Ren <jianqi.ren.cn@windriver.com>
Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent-tree.c

index a8089bf2be98b6938ecab98bebe877624a6ea4bf..cf2b65be04b5a4ddb0f098795405fc018afd3f44 100644 (file)
@@ -5240,7 +5240,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(root->root_key.objectid)) {
                                ret = btrfs_qgroup_trace_leaf_items(trans, eb);
                                if (ret) {