i965: Write a custom allocator for the intel memobj struct

This helps ensure we're not doing out of bounds access later.

Signed-off-by: Rohan Garg <rohan.garg@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12075>
This commit is contained in:
Rohan Garg
2021-07-27 12:32:24 +02:00
committed by Marge Bot
parent 1f0964d6b6
commit 9375f62a54
+12
View File
@@ -139,6 +139,17 @@ brw_set_background_context(struct gl_context *ctx,
backgroundCallable->setBackgroundContext(driContext->loaderPrivate);
}
static struct gl_memory_object *
brw_new_memoryobj(struct gl_context *ctx, GLuint name)
{
struct brw_memory_object *memory_object = CALLOC_STRUCT(brw_memory_object);
if (!memory_object)
return NULL;
_mesa_initialize_memory_object(ctx, &memory_object->Base, name);
return &memory_object->Base;
}
static void
brw_delete_memoryobj(struct gl_context *ctx, struct gl_memory_object *memObj)
{
@@ -441,6 +452,7 @@ brw_init_driver_functions(struct brw_context *brw,
functions->SetBackgroundContext = brw_set_background_context;
functions->NewMemoryObject = brw_new_memoryobj;
functions->DeleteMemoryObject = brw_delete_memoryobj;
functions->ImportMemoryObjectFd = brw_import_memoryobj_fd;
functions->GetDeviceUuid = brw_get_device_uuid;