From d10fa7e4d3d37d34d7b0fd51e6380c2ddaf210cb 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: (cherry picked from commit a8ff1bdc8331303f5830a09a5ab2dd3d4016fd8c) --- .pick_status.json | 2 +- src/gallium/drivers/llvmpipe/lp_texture.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 93d492336a1..58e4f0e94a4 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1224,7 +1224,7 @@ "description": "llvmpipe: handle vma allocation failure", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "a062544d3d0519aaa3845b7cfd79e925b9352a55", "notes": null 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 */