From 75d5c1229e1fcc0e0885b35a1cc23e66a90aeb84 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 23 Feb 2021 10:44:36 -0500 Subject: [PATCH] i915: use align_calloc for the context to fix m32 crashes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes: 3175b63a0dfa290 "mesa: don't allocate matrices with malloc" Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4295 Reviewed-by: Eric Anholt Reviewed-by: Zoltán Böszörményi Part-of: --- src/mesa/drivers/dri/i915/i830_context.c | 5 +++-- src/mesa/drivers/dri/i915/i915_context.c | 5 +++-- src/mesa/drivers/dri/i915/intel_context.c | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_context.c b/src/mesa/drivers/dri/i915/i830_context.c index e8ce5ad..cea893f 100644 --- a/src/mesa/drivers/dri/i915/i830_context.c +++ b/src/mesa/drivers/dri/i915/i830_context.c @@ -36,6 +36,7 @@ #include "tnl/t_pipeline.h" #include "intel_tris.h" #include "util/ralloc.h" +#include "util/u_memory.h" /*************************************** * Mesa's Driver Functions @@ -61,7 +62,7 @@ i830CreateContext(int api, void *sharedContextPrivate) { struct dd_function_table functions; - struct i830_context *i830 = rzalloc(NULL, struct i830_context); + struct i830_context *i830 = align_calloc(sizeof(struct i830_context), 16); struct intel_context *intel = &i830->intel; struct gl_context *ctx = &intel->ctx; @@ -78,7 +79,7 @@ i830CreateContext(int api, mesaVis, driContextPriv, sharedContextPrivate, &functions, error)) { - ralloc_free(i830); + align_free(i830); return false; } diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index be6d3d8..00877da 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -38,6 +38,7 @@ #include "tnl/t_context.h" #include "tnl/t_pipeline.h" #include "tnl/t_vertex.h" +#include "util/u_memory.h" #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" @@ -165,7 +166,7 @@ i915CreateContext(int api, void *sharedContextPrivate) { struct dd_function_table functions; - struct i915_context *i915 = rzalloc(NULL, struct i915_context); + struct i915_context *i915 = align_calloc(sizeof(struct i915_context), 16); struct intel_context *intel = &i915->intel; struct gl_context *ctx = &intel->ctx; @@ -182,7 +183,7 @@ i915CreateContext(int api, mesaVis, driContextPriv, sharedContextPrivate, &functions, error)) { - ralloc_free(i915); + align_free(i915); return false; } diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index cacc4e9..7355e03 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -57,6 +57,7 @@ #include "utils.h" #include "util/debug.h" #include "util/ralloc.h" +#include "util/u_memory.h" int INTEL_DEBUG = (0); @@ -600,7 +601,7 @@ intelDestroyContext(__DRIcontext * driContextPriv) /* free the Mesa context */ _mesa_free_context_data(&intel->ctx, true); - ralloc_free(intel); + align_free(intel); driContextPriv->driverPrivate = NULL; } } -- 2.7.4