[Mesa-dev] [PATCH] i965: Do null pointer check before dereferencing vue_prog_data

Nanley Chery nanleychery at gmail.com
Wed Feb 7 00:38:00 UTC 2018


On Mon, Feb 05, 2018 at 04:08:40PM -0800, Anuj Phogat wrote:
> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
> ---
>  src/mesa/drivers/dri/i965/genX_state_upload.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
> index aa4d64d08e..67fb328dbc 100644
> --- a/src/mesa/drivers/dri/i965/genX_state_upload.c
> +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
> @@ -3966,7 +3966,8 @@ genX(upload_ds_state)(struct brw_context *brw)
>             tes_prog_data->domain == BRW_TESS_DOMAIN_TRI;
>  
>  #if GEN_GEN >= 8
> -        if (vue_prog_data->dispatch_mode == DISPATCH_MODE_SIMD8)
> +        if (vue_prog_data &&
> +            vue_prog_data->dispatch_mode == DISPATCH_MODE_SIMD8)

In this else case (where tes_prog_data != NULL) this variable is also
guaranteed to be non-NULL. They point to the same location in memory as
far as I can tell.

Though, what I find confusing is that we can simultaneously access
fields of struct brw_tes_prog_data as well as struct brw_vue_prog_data
even though neither is a subclass of the other.

>             ds.DispatchMode = DISPATCH_MODE_SIMD8_SINGLE_PATCH;
>          ds.UserClipDistanceCullTestEnableBitmask =
>              vue_prog_data->cull_distance_mask;
> -- 
> 2.13.6
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list