i915: use align_calloc for the context to fix m32 crashes

Fixes: 3175b63a0d "mesa: don't allocate matrices with malloc"
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4295

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9220>
(cherry picked from commit 75d5c1229e)
This commit is contained in:
Marek Olšák 2021-02-23 10:44:36 -05:00 committed by Dylan Baker
parent da65216e9d
commit 00c346d277
4 changed files with 9 additions and 6 deletions

View file

@ -778,7 +778,7 @@
"description": "i915: use align_calloc for the context to fix m32 crashes",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "3175b63a0dfa290430f9f7eb651387788933a02b"
},

View file

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

View file

@ -37,6 +37,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"
@ -164,7 +165,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;
@ -181,7 +182,7 @@ i915CreateContext(int api,
mesaVis, driContextPriv,
sharedContextPrivate, &functions,
error)) {
ralloc_free(i915);
align_free(i915);
return false;
}

View file

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