From: David Sterba Date: Wed, 30 Apr 2025 16:45:21 +0000 (+0200) Subject: btrfs: move transaction aborts to the error site in add_to_free_space_tree() X-Git-Tag: v6.16-rc1~214^2~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c4cfa99c2cdf90c2444167d9aab075885019936;p=thirdparty%2Flinux.git btrfs: move transaction aborts to the error site in add_to_free_space_tree() Transaction aborts should be done next to the place the error happens, which was not done in add_to_free_space_tree(). Signed-off-by: David Sterba --- diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index ffe98bea6927f..0c573d46639ae 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c @@ -1045,6 +1045,7 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans, path = btrfs_alloc_path(); if (!path) { ret = -ENOMEM; + btrfs_abort_transaction(trans, ret); goto out; } @@ -1052,18 +1053,19 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans, if (!block_group) { DEBUG_WARN("no block group found for start=%llu", start); ret = -ENOENT; + btrfs_abort_transaction(trans, ret); goto out; } mutex_lock(&block_group->free_space_lock); ret = __add_to_free_space_tree(trans, block_group, path, start, size); mutex_unlock(&block_group->free_space_lock); + if (ret) + btrfs_abort_transaction(trans, ret); btrfs_put_block_group(block_group); out: btrfs_free_path(path); - if (ret) - btrfs_abort_transaction(trans, ret); return ret; }