[Mesa-dev] [PATCH] radeonsi: check if value is negative
Jakob Sinclair
sinclair.jakob at openmailbox.org
Wed Apr 27 18:07:10 UTC 2016
On 2016-04-27 12:17, Marek Olšák wrote:
> Reviewed-by: Marek Olšák <marek.olsak at amd.com>
>
> Marek
>
> On Mon, Apr 25, 2016 at 9:03 AM, Jakob Sinclair
> <sinclair.jakob at openmailbox.org> wrote:
>> Fixes a Coverity defect by adding checks to see if a value is negative
>> before using it to index an array. By checking the value first it
>> makes
>> the code a bit safer but overall should not have a big impact.
>>
>> CID: 1355598
>>
>> Signed-off-by: Jakob Sinclair <sinclair.jakob at openmailbox.org>
>> ---
>>
>> Resending this patch because I did not get any response last time.
>>
>> src/gallium/drivers/radeonsi/si_state.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/drivers/radeonsi/si_state.c
>> b/src/gallium/drivers/radeonsi/si_state.c
>> index 7ae6e8a..8bd527b 100644
>> --- a/src/gallium/drivers/radeonsi/si_state.c
>> +++ b/src/gallium/drivers/radeonsi/si_state.c
>> @@ -1762,6 +1762,9 @@ static uint32_t
>> si_translate_buffer_dataformat(struct pipe_screen *screen,
>> const struct
>> util_format_description *desc,
>> int first_non_void)
>> {
>> + if (first_non_void < 0)
>> + return V_008F0C_BUF_DATA_FORMAT_INVALID;
>> +
>> unsigned type = desc->channel[first_non_void].type;
>> int i;
>>
>> @@ -1836,7 +1839,7 @@ static uint32_t
>> si_translate_buffer_numformat(struct pipe_screen *screen,
>> const struct
>> util_format_description *desc,
>> int first_non_void)
>> {
>> - if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT)
>> + if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT ||
>> first_non_void < 0)
>> return V_008F0C_BUF_NUM_FORMAT_FLOAT;
>>
>> switch (desc->channel[first_non_void].type) {
>> --
>> 2.8.0
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Thanks for reviewing! I forgot to mention that I don't have push access
yet so it would be very nice if you could push it for me.
--
Mvh Jakob Sinclair
More information about the mesa-dev
mailing list