linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Fix unsigned variable compared to less than zero
@ 2019-11-11 17:25 Gustavo A. R. Silva
  2019-11-11 17:46 ` Mikita Lipski
  0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2019-11-11 17:25 UTC (permalink / raw)
  To: Harry Wentland, Leo Li, Alex Deucher, Christian König,
	David (ChunMing) Zhou, David Airlie, Daniel Vetter,
	Mikita Lipski, Lyude Paul, Nicholas Kazlauskas
  Cc: amd-gfx, dri-devel, linux-kernel, Gustavo A. R. Silva

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@embeddedor.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amd/display: Fix unsigned variable compared to less than zero
  2019-11-11 17:25 [PATCH] drm/amd/display: Fix unsigned variable compared to less than zero Gustavo A. R. Silva
@ 2019-11-11 17:46 ` Mikita Lipski
  2019-11-11 19:27   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 4+ messages in thread
From: Mikita Lipski @ 2019-11-11 17:46 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Harry Wentland, Leo Li, Alex Deucher,
	Christian König, David (ChunMing) Zhou, David Airlie,
	Daniel Vetter, Mikita Lipski, Lyude Paul, Nicholas Kazlauskas
  Cc: amd-gfx, dri-devel, linux-kernel


Thanks for catching it!

Reviewed-by: Mikita Lipski <mikita.lipski@amd.com>


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@embeddedor.com>
> ---
>   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

-- 
Thanks,
Mikita Lipski
Software Engineer, AMD
mikita.lipski@amd.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amd/display: Fix unsigned variable compared to less than zero
  2019-11-11 17:46 ` Mikita Lipski
@ 2019-11-11 19:27   ` Gustavo A. R. Silva
  2019-11-11 22:39     ` Alex Deucher
  0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2019-11-11 19:27 UTC (permalink / raw)
  To: Mikita Lipski, Harry Wentland, Leo Li, Alex Deucher,
	Christian König, David (ChunMing) Zhou, David Airlie,
	Daniel Vetter, Mikita Lipski, Lyude Paul, Nicholas Kazlauskas
  Cc: amd-gfx, dri-devel, linux-kernel



On 11/11/19 11:46, Mikita Lipski wrote:
> 
> Thanks for catching it!
> 

Glad to help out. :)

> Reviewed-by: Mikita Lipski <mikita.lipski@amd.com>
> 

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@embeddedor.com>
>> ---
>>   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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amd/display: Fix unsigned variable compared to less than zero
  2019-11-11 19:27   ` Gustavo A. R. Silva
@ 2019-11-11 22:39     ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2019-11-11 22:39 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Mikita Lipski, Harry Wentland, Leo Li, Alex Deucher,
	Christian König, David (ChunMing) Zhou, David Airlie,
	Daniel Vetter, Mikita Lipski, Lyude Paul, Nicholas Kazlauskas,
	Maling list - DRI developers, amd-gfx list, LKML

Applied.  Thanks!

Alex

On Mon, Nov 11, 2019 at 2:44 PM Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
>
>
>
> On 11/11/19 11:46, Mikita Lipski wrote:
> >
> > Thanks for catching it!
> >
>
> Glad to help out. :)
>
> > Reviewed-by: Mikita Lipski <mikita.lipski@amd.com>
> >
>
> 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@embeddedor.com>
> >> ---
> >>   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
> >
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-11 22:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 17:25 [PATCH] drm/amd/display: Fix unsigned variable compared to less than zero Gustavo A. R. Silva
2019-11-11 17:46 ` Mikita Lipski
2019-11-11 19:27   ` Gustavo A. R. Silva
2019-11-11 22:39     ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).