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 <mark@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28253>
This commit is contained in:
Mark Collins 2024-03-18 11:08:28 +00:00 committed by Marge Bot
parent e0a680162d
commit 694ed34673

View file

@ -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);
}