From: Haoxiang Li <haoxiang_li2024@xxxxxxx> commit 35d99c68af40a8ca175babc5a89ef7e2226fb3ca upstream. 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@xxxxxxxxxxxxxxx Reviewed-by: Qu Wenruo <wqu@xxxxxxxx> Reviewed-by: Filipe Manana <fdmanana@xxxxxxxx> Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/volumes.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -7094,6 +7094,7 @@ static int read_one_chunk(struct btrfs_k 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; Patches currently in stable-queue which might be from haoxiang_li2024@xxxxxxx are queue-6.12/btrfs-fix-a-leaked-chunk-map-issue-in-read_one_chunk.patch