radeonsi: Add missing error-checking to si_create_compute_state (v2)
authorMun Gwan-gyeong <elongbug@gmail.com>
Mon, 21 Nov 2016 14:20:43 +0000 (23:20 +0900)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 21 Nov 2016 20:09:06 +0000 (21:09 +0100)
When the uploading of shader fails on si_shader_binary_upload(),
it returns -ENOMEM. We should handle si_shader_binary_upload() failure path
on si_create_compute_state().

CID 1394027

v2: Fixes from Edward O'Callaghan's review
 a) Update explicitly return value check with "si_shader_binary_upload() < 0"
 b) Update commit message.

Signed-off-by: Mun Gwan-gyeong <elongbug@gmail.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_compute.c

index 69d57b9a61666cc2aea6fea6dbe12c9759715e9c..e53ffa4cc7261dfbb088112477f2b7a5e75fedad 100644 (file)
@@ -170,7 +170,11 @@ static void *si_create_compute_state(
                }
                si_shader_dump(sctx->screen, &program->shader, &sctx->b.debug,
                               PIPE_SHADER_COMPUTE, stderr);
-               si_shader_binary_upload(sctx->screen, &program->shader);
+               if (si_shader_binary_upload(sctx->screen, &program->shader) < 0) {
+                       fprintf(stderr, "LLVM failed to upload shader\n");
+                       FREE(program);
+                       return NULL;
+               }
        }
 
        return program;