From: Haoxiang Li Date: Mon, 3 Mar 2025 02:42:33 +0000 (+0800) Subject: btrfs: fix a leaked chunk map issue in read_one_chunk() X-Git-Tag: v6.14-rc6~13^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=35d99c68af40a8ca175babc5a89ef7e2226fb3ca;p=thirdparty%2Fkernel%2Flinux.git btrfs: fix a leaked chunk map issue in read_one_chunk() Add btrfs_free_chunk_map() to free the memory allocated by btrfs_alloc_chunk_map() if btrfs_add_chunk_map() fails. Fixes: 7dc66abb5a47 ("btrfs: use a dedicated data structure for chunk maps") CC: stable@vger.kernel.org Reviewed-by: Qu Wenruo Reviewed-by: Filipe Manana Signed-off-by: Haoxiang Li Signed-off-by: David Sterba --- diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index f6ae76815e4b5..6f8dcf59b5257 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -7151,6 +7151,7 @@ static int read_one_chunk(struct btrfs_key *key, struct extent_buffer *leaf, btrfs_err(fs_info, "failed to add chunk map, start=%llu len=%llu: %d", map->start, map->chunk_len, ret); + btrfs_free_chunk_map(map); } return ret;