From 694ed34673294861667ad37331fd2419c4695979 Mon Sep 17 00:00:00 2001 From: Mark Collins Date: Mon, 18 Mar 2024 11:08:28 +0000 Subject: [PATCH] fd/replay: Error when VMA AS allocation fails It's possible for large allocations to hit the maximum address space size especially with a fake AS, these failures are silent and can cause a hard to debug segfault later down the line. Signed-off-by: Mark Collins Part-of: --- src/freedreno/decode/replay.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/freedreno/decode/replay.c b/src/freedreno/decode/replay.c index 633cc811b6d..8d1c4ec2501 100644 --- a/src/freedreno/decode/replay.c +++ b/src/freedreno/decode/replay.c @@ -620,7 +620,9 @@ device_submit_cmdstreams(struct device *dev) static void buffer_mem_alloc(struct device *dev, struct buffer *buf) { - util_vma_heap_alloc_addr(&dev->vma, buf->iova, buf->size); + bool success = util_vma_heap_alloc_addr(&dev->vma, buf->iova, buf->size); + if (!success) + errx(1, "Failed to allocate buffer"); if (!dev->has_set_iova) { uint64_t offset = buf->iova - dev->va_iova; @@ -832,7 +834,9 @@ device_submit_cmdstreams(struct device *dev) static void buffer_mem_alloc(struct device *dev, struct buffer *buf) { - util_vma_heap_alloc_addr(&dev->vma, buf->iova, buf->size); + bool success = util_vma_heap_alloc_addr(&dev->vma, buf->iova, buf->size); + if (!success) + errx(1, "Failed to allocate buffer"); buf->map = ((uint8_t*)dev->va_map) + (buf->iova - dev->va_iova); } @@ -1196,7 +1200,9 @@ device_submit_cmdstreams(struct device *dev) static void buffer_mem_alloc(struct device *dev, struct buffer *buf) { - util_vma_heap_alloc_addr(&dev->vma, buf->iova, buf->size); + bool success = util_vma_heap_alloc_addr(&dev->vma, buf->iova, buf->size); + if (!success) + errx(1, "Failed to allocate buffer"); buf->map = ((uint8_t*)dev->va_map) + (buf->iova - dev->va_iova); }