[Mesa-dev] [PATCH] i965: check tcs for NULL dereference

Kenneth Graunke kenneth at whitecape.org
Fri May 13 22:39:40 UTC 2016


On Friday, May 13, 2016 1:11:28 PM PDT Mark Janes wrote:
> Coverity issue 1361544 found an instance where the tcs variable is
> checked for NULL, but unconditionally dereferenced later in the same
> function.
> 
> CC: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_tcs.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/
i965/brw_tcs.c
> index e8178c6..9589fa5 100644
> --- a/src/mesa/drivers/dri/i965/brw_tcs.c
> +++ b/src/mesa/drivers/dri/i965/brw_tcs.c
> @@ -278,14 +278,16 @@ brw_codegen_tcs_prog(struct brw_context *brw,
>  
>     if (unlikely(brw->perf_debug)) {
>        struct brw_shader *btcs = (struct brw_shader *) tcs;
> -      if (btcs->compiled_once) {
> -         brw_tcs_debug_recompile(brw, shader_prog, key);
> +      if (btcs) {
> +         if (btcs->compiled_once) {
> +            brw_tcs_debug_recompile(brw, shader_prog, key);
> +         }
> +         btcs->compiled_once = true;
>        }
>        if (start_busy && !drm_intel_bo_busy(brw->batch.last_bo)) {
>           perf_debug("TCS compile took %.03f ms and stalled the GPU\n",
>                      (get_time() - start_time) * 1000);
>        }
> -      btcs->compiled_once = true;
>     }
>  
>     /* Scratch space is used for register spilling */
> 

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160513/1f1409bf/attachment.sig>


More information about the mesa-dev mailing list