[Mesa-dev] [PATCH] radeonsi: reject invalid vertex element formats

Edward O'Callaghan funfunctor at folklore1984.net
Thu Jan 19 12:41:28 UTC 2017


Reviewed-by: Edward O'Callaghan <funfunctor at folklore1984.net>

On 01/19/2017 08:35 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> This should fix a coverity defect.
> ---
>  src/gallium/drivers/radeonsi/si_state.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
> index f60a499..5bc1789 100644
> --- a/src/gallium/drivers/radeonsi/si_state.c
> +++ b/src/gallium/drivers/radeonsi/si_state.c
> @@ -3343,20 +3343,25 @@ static void *si_create_vertex_elements(struct pipe_context *ctx,
>  			return NULL;
>  		}
>  
>  		if (!used[vbo_index]) {
>  			v->first_vb_use_mask |= 1 << i;
>  			used[vbo_index] = true;
>  		}
>  
>  		desc = util_format_description(elements[i].src_format);
>  		first_non_void = util_format_get_first_non_void_channel(elements[i].src_format);
> +		if (first_non_void < 0) {
> +			FREE(v);
> +			return NULL;
> +		}
> +
>  		data_format = si_translate_buffer_dataformat(ctx->screen, desc, first_non_void);
>  		num_format = si_translate_buffer_numformat(ctx->screen, desc, first_non_void);
>  		channel = &desc->channel[first_non_void];
>  
>  		v->rsrc_word3[i] = S_008F0C_DST_SEL_X(si_map_swizzle(desc->swizzle[0])) |
>  				   S_008F0C_DST_SEL_Y(si_map_swizzle(desc->swizzle[1])) |
>  				   S_008F0C_DST_SEL_Z(si_map_swizzle(desc->swizzle[2])) |
>  				   S_008F0C_DST_SEL_W(si_map_swizzle(desc->swizzle[3])) |
>  				   S_008F0C_NUM_FORMAT(num_format) |
>  				   S_008F0C_DATA_FORMAT(data_format);
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170119/5ce22b82/attachment.sig>


More information about the mesa-dev mailing list