[Mesa-dev] [PATCH] radeonsi: reject invalid vertex element formats
Nicolai Hähnle
nhaehnle at gmail.com
Thu Jan 19 08:19:38 UTC 2017
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
On 18.01.2017 22:35, 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);
>
More information about the mesa-dev
mailing list