From: Robert Foss <robert.f...@collabora.com> Make fd2_program_validate return failure information to avoid de-allocated memory from being used.
coverity: 1362467 Signed-off-by: Robert Foss <robert.f...@collabora.com> --- src/gallium/drivers/freedreno/a2xx/fd2_program.c | 12 +++++++++--- src/gallium/drivers/freedreno/a2xx/fd2_program.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_program.c b/src/gallium/drivers/freedreno/a2xx/fd2_program.c index 4f31772..1819c52 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_program.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_program.c @@ -237,7 +237,7 @@ patch_tex_fetches(struct fd_context *ctx, struct fd2_shader_stateobj *so, } } -void +bool fd2_program_validate(struct fd_context *ctx) { struct fd_program_stateobj *prog = &ctx->prog; @@ -248,10 +248,14 @@ fd2_program_validate(struct fd_context *ctx) * need to recompile both vert and frag shader. */ if (ctx->dirty & FD_SHADER_DIRTY_FP) - compile(prog, prog->fp); + { + if (compile(prog, prog->fp) == NULL) + return false; + } if (ctx->dirty & (FD_SHADER_DIRTY_FP | FD_SHADER_DIRTY_VP)) - compile(prog, prog->vp); + if (compile(prog, prog->vp) == NULL) + return false; /* if necessary, fix up vertex fetch instructions: */ if (ctx->dirty & (FD_DIRTY_VTXSTATE | FD_DIRTY_PROG)) @@ -262,6 +266,8 @@ fd2_program_validate(struct fd_context *ctx) patch_tex_fetches(ctx, prog->vp, &ctx->verttex); patch_tex_fetches(ctx, prog->fp, &ctx->fragtex); } + + return true; } void diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_program.h b/src/gallium/drivers/freedreno/a2xx/fd2_program.h index 170b22a..935661c 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_program.h +++ b/src/gallium/drivers/freedreno/a2xx/fd2_program.h @@ -74,7 +74,7 @@ struct fd2_shader_stateobj { void fd2_program_emit(struct fd_ringbuffer *ring, struct fd_program_stateobj *prog); -void fd2_program_validate(struct fd_context *ctx); +bool fd2_program_validate(struct fd_context *ctx); void fd2_prog_init(struct pipe_context *pctx); -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev