Re: [PATCH] drm/amd/display: Fix unsigned variable compared to less than zero
From: Gustavo A. R. Silva
Date: Mon Nov 11 2019 - 14:27:02 EST
On 11/11/19 11:46, Mikita Lipski wrote:
>
> Thanks for catching it!
>
Glad to help out. :)
> Reviewed-by: Mikita Lipski <mikita.lipski@xxxxxxx>
>
Thanks
--
Gustavo
>
> On 11.11.2019 12:25, Gustavo A. R. Silva wrote:
>> Currenly, the error check below on variable*vcpi_slots*Â is always
>> false because it is a uint64_t type variable, hence, the values
>> this variable can hold are never less than zero:
>>
>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:
>> 4870ÂÂÂÂÂÂÂÂ if (dm_new_connector_state->vcpi_slots < 0) {
>> 4871ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ DRM_DEBUG_ATOMIC("failed finding vcpi slots: %d\n", (int)dm_new_connector_statÂÂÂÂ e->vcpi_slots);
>> 4872ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return dm_new_connector_state->vcpi_slots;
>> 4873ÂÂÂÂÂÂÂÂ }
>>
>> Fix this by making*vcpi_slots*Â of int type
>>
>> Addresses-Coverity: 1487838 ("Unsigned compared against 0")
>> Fixes: b4c578f08378 ("drm/amd/display: Add MST atomic routines")
>> Signed-off-by: Gustavo A. R. Silva<gustavo@xxxxxxxxxxxxxx>
>> ---
>> Â drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 2 +-
>> Â 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
>> index 6db07e9e33ab..a8fc90a927d6 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
>> @@ -403,7 +403,7 @@ struct dm_connector_state {
>> ÂÂÂÂÂ bool underscan_enable;
>> ÂÂÂÂÂ bool freesync_capable;
>> ÂÂÂÂÂ uint8_t abm_level;
>> -ÂÂÂ uint64_t vcpi_slots;
>> +ÂÂÂ int vcpi_slots;
>> ÂÂÂÂÂ uint64_t pbn;
>> Â };
>> Â -- 2.23.0
>