[Mesa-dev] [PATCH 07/17] radeonsi: add malloc fail paths to si_create_shader_state

Marek Olšák maraeo at gmail.com
Thu Sep 10 10:56:30 PDT 2015


From: Marek Olšák <marek.olsak at amd.com>

Cc: 11.0 <mesa-stable at lists.freedesktop.org>
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index db45cc1..1f1965f 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -666,8 +666,16 @@ static void *si_create_shader_state(struct pipe_context *ctx,
 	struct si_shader_selector *sel = CALLOC_STRUCT(si_shader_selector);
 	int i;
 
+	if (!sel)
+		return NULL;
+
 	sel->type = pipe_shader_type;
 	sel->tokens = tgsi_dup_tokens(state->tokens);
+	if (!sel->tokens) {
+		FREE(sel);
+		return NULL;
+	}
+
 	sel->so = state->stream_output;
 	tgsi_scan_shader(state->tokens, &sel->info);
 	p_atomic_inc(&sscreen->b.num_shaders_created);
-- 
2.1.4



More information about the mesa-dev mailing list