radeonsi: add malloc fail paths to si_create_shader_state
authorMarek Olšák <marek.olsak@amd.com>
Thu, 10 Sep 2015 16:16:26 +0000 (18:16 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 24 Sep 2015 17:51:42 +0000 (19:51 +0200)
Cc: 11.0 <mesa-stable@lists.freedesktop.org>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_state_shaders.c

index db45cc181c60cb6b4995cd54503393f85e8a0e3a..1f1965f6a56eab24313563f0a9dcd81d3638c0e9 100644 (file)
@@ -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);