From 81cf4bef7e83fe3174503d48b458f8596420fdd7 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] radeon,r200: 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" Reviewed-by: Eric Anholt Reviewed-by: Zoltán Böszörményi Part-of: --- src/mesa/drivers/dri/r200/r200_context.c | 5 +++-- src/mesa/drivers/dri/radeon/radeon_common_context.c | 3 ++- src/mesa/drivers/dri/radeon/radeon_context.c | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index efcf986..e804451 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -66,6 +66,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "utils.h" #include "util/driconf.h" /* for symbolic values of enum-type options */ +#include "util/u_memory.h" /* Return various strings for glGetString(). */ @@ -200,7 +201,7 @@ GLboolean r200CreateContext( gl_api api, assert(screen); /* Allocate the R200 context */ - rmesa = calloc(1, sizeof(*rmesa)); + rmesa = align_calloc(sizeof(*rmesa), 16); if ( !rmesa ) { *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; @@ -238,7 +239,7 @@ GLboolean r200CreateContext( gl_api api, if (!radeonInitContext(&rmesa->radeon, api, &functions, glVisual, driContextPriv, sharedContextPrivate)) { - free(rmesa); + align_free(rmesa); *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; } diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c index 622b38e..fbe8b8e 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c @@ -45,6 +45,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" #include "tnl/tnl.h" +#include "util/u_memory.h" #ifndef RADEON_DEBUG int RADEON_DEBUG = (0); @@ -286,7 +287,7 @@ void radeonDestroyContext(__DRIcontext *driContextPriv ) fclose(track); } #endif - free(radeon); + align_free(radeon); } /* Force the context `c' to be unbound from its buffer. diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 3c80963..497a566 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -67,6 +67,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "utils.h" #include "util/driconf.h" /* for symbolic values of enum-type options */ +#include "util/u_memory.h" extern const struct tnl_pipeline_stage _radeon_render_stage; extern const struct tnl_pipeline_stage _radeon_tcl_stage; @@ -165,7 +166,7 @@ r100CreateContext( gl_api api, assert(screen); /* Allocate the Radeon context */ - rmesa = calloc(1, sizeof(*rmesa)); + rmesa = align_calloc(sizeof(*rmesa), 16); if ( !rmesa ) { *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; @@ -200,7 +201,7 @@ r100CreateContext( gl_api api, if (!radeonInitContext(&rmesa->radeon, api, &functions, glVisual, driContextPriv, sharedContextPrivate)) { - free(rmesa); + align_free(rmesa); *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; } -- 2.7.4