From 580046e49faa88bb6d9c183f491f2779de1769f3 Mon Sep 17 00:00:00 2001 From: Victor Hermann Chiletto Date: Fri, 13 May 2022 02:53:18 -0300 Subject: [PATCH] radv: always check entry count in descriptor pool when allocating Previously this check was skipped for pools with VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT unset, but after 96a240e1 we need to check this otherwise we risk overflowing radv_descriptor_pool::entries into the host memory base This fixes a crash to desktop when launching Dota 2, which overallocates descriptor sets and expects an error to allocate another descriptor pool Fixes: 96a240e1767 ("radv: fix memory leak of descriptor set layout") Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_descriptor_set.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c index 81df56438e7..6c167d81797 100644 --- a/src/amd/vulkan/radv_descriptor_set.c +++ b/src/amd/vulkan/radv_descriptor_set.c @@ -679,8 +679,11 @@ radv_descriptor_set_create(struct radv_device *device, struct radv_descriptor_po layout_size = align_u32(layout_size, 32); set->header.size = layout_size; - if (!pool->host_memory_base && pool->entry_count == pool->max_entry_count) { - vk_free2(&device->vk.alloc, NULL, set); + if (pool->entry_count == pool->max_entry_count) { + if (!pool->host_memory_base) { + vk_free2(&device->vk.alloc, NULL, set); + } + return VK_ERROR_OUT_OF_POOL_MEMORY; }