From a8ff1bdc8331303f5830a09a5ab2dd3d4016fd8c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 17 Jul 2024 12:36:45 -0400 Subject: [PATCH] llvmpipe: handle vma allocation failure Fixes: a062544d3d0 ("llvmpipe: Use an anonymous file for memory allocations") Reviewed-by: Konstantin Seurer Part-of: --- src/gallium/drivers/llvmpipe/lp_texture.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 30d5057cf9f..9bd6ce5a4a0 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -1305,6 +1305,11 @@ llvmpipe_allocate_memory(struct pipe_screen *_screen, uint64_t size) mtx_lock(&screen->mem_mutex); mem->offset = util_vma_heap_alloc(&screen->mem_heap, mem->size, alignment); + if (!mem->offset) { + mtx_unlock(&screen->mem_mutex); + FREE(mem); + return NULL; + } if (mem->offset + mem->size > screen->mem_file_size) { /* expand the anonymous file */