Commit 009ca358 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba
Browse files

btrfs: tests: fix chunk map leak after failure to add it to the tree



If we fail to add the chunk map to the fs mapping tree we exit
test_rmap_block() without freeing the chunk map. Fix this by adding a
call to btrfs_free_chunk_map() before exiting the test function if the
call to btrfs_add_chunk_map() failed.

Fixes: 7dc66abb ("btrfs: use a dedicated data structure for chunk maps")
CC: stable@vger.kernel.org # 6.12+
Reviewed-by: default avatarBoris Burkov <boris@bur.io>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 0497dfba
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1045,6 +1045,7 @@ static int test_rmap_block(struct btrfs_fs_info *fs_info,
	ret = btrfs_add_chunk_map(fs_info, map);
	if (ret) {
		test_err("error adding chunk map to mapping tree");
		btrfs_free_chunk_map(map);
		goto out_free;
	}