For a variety of reasons mmap (selinux and pax to name
a few) and can fail and with current code. This will
result in a crash in the driver, if not worse.
This has been the case since the inception of the
gallium copy of rtasm.
Cc: 9.1 9.2 10.0 <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73473
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
static unsigned char *exec_mem = NULL;
-static void
+static int
init_heap(void)
{
if (!exec_heap)
exec_mem = (unsigned char *) mmap(0, EXEC_HEAP_SIZE,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+ return (exec_mem != MAP_FAILED);
}
pipe_mutex_lock(exec_mutex);
- init_heap();
+ if (!init_heap())
+ goto bail;
if (exec_heap) {
size = (size + 31) & ~31; /* next multiple of 32 bytes */
addr = exec_mem + block->ofs;
else
debug_printf("rtasm_exec_malloc failed\n");
-
+
+bail:
pipe_mutex_unlock(exec_mutex);
return addr;