btrfs: use BTRFS_PATH_AUTO_FREE in populate_free_space_tree()
authorDavid Sterba <dsterba@suse.com>
Mon, 24 Feb 2025 08:15:17 +0000 (09:15 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Mar 2025 19:35:48 +0000 (20:35 +0100)
This is the trivial pattern for path auto free, initialize at the
beginning and free at the end with simple goto -> return conversions.
This applies to both path and path2.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/free-space-tree.c

index cae540ec15edad8de7c5a05a08bf527faafe773b..d1ec02d5e1f6a9d6c3adda2215c2b31e90dd7d80 100644 (file)
@@ -1062,7 +1062,8 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans,
                                    struct btrfs_block_group *block_group)
 {
        struct btrfs_root *extent_root;
-       struct btrfs_path *path, *path2;
+       BTRFS_PATH_AUTO_FREE(path);
+       BTRFS_PATH_AUTO_FREE(path2);
        struct btrfs_key key;
        u64 start, end;
        int ret;
@@ -1070,17 +1071,16 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans,
        path = btrfs_alloc_path();
        if (!path)
                return -ENOMEM;
-       path->reada = READA_FORWARD;
 
        path2 = btrfs_alloc_path();
-       if (!path2) {
-               btrfs_free_path(path);
+       if (!path2)
                return -ENOMEM;
-       }
+
+       path->reada = READA_FORWARD;
 
        ret = add_new_free_space_info(trans, block_group, path2);
        if (ret)
-               goto out;
+               return ret;
 
        mutex_lock(&block_group->free_space_lock);
 
@@ -1146,9 +1146,7 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans,
        ret = 0;
 out_locked:
        mutex_unlock(&block_group->free_space_lock);
-out:
-       btrfs_free_path(path2);
-       btrfs_free_path(path);
+
        return ret;
 }