drm/amd/display: Use int for signed error code checks in commit planes

Submitted by Nicholas Kazlauskas on May 2, 2019, 1:03 p.m.

Details

Message ID 20190502130317.5506-1-nicholas.kazlauskas@amd.com
State New
Headers show
Series "drm/amd/display: Use int for signed error code checks in commit planes" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Nicholas Kazlauskas May 2, 2019, 1:03 p.m.
[Why]

The type of 'r' is uint32_t and the return codes for both:

- reservation_object_wait_timeout_rcu
- amdgpu_bo_reserve

...are signed. While it works for the latter since the check is
done on != 0 it doesn't work for the former since we check <= 0.

[How]

Make 'r' an int in commit planes so we're not doing any unsigned/signed
conversion here in the first place.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index becd8cb3aab6..722f863ce4a4 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5332,7 +5332,7 @@  static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 				    struct drm_crtc *pcrtc,
 				    bool wait_for_vblank)
 {
-	uint32_t i, r;
+	uint32_t i;
 	uint64_t timestamp_ns;
 	struct drm_plane *plane;
 	struct drm_plane_state *old_plane_state, *new_plane_state;
@@ -5342,7 +5342,7 @@  static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 	struct dm_crtc_state *acrtc_state = to_dm_crtc_state(new_pcrtc_state);
 	struct dm_crtc_state *dm_old_crtc_state =
 			to_dm_crtc_state(drm_atomic_get_old_crtc_state(state, pcrtc));
-	int planes_count = 0, vpos, hpos;
+	int r, planes_count = 0, vpos, hpos;
 	unsigned long flags;
 	struct amdgpu_bo *abo;
 	uint64_t tiling_flags;

Comments

Am 02.05.19 um 15:03 schrieb Nicholas Kazlauskas:
> [Why]
>
> The type of 'r' is uint32_t and the return codes for both:
>
> - reservation_object_wait_timeout_rcu
> - amdgpu_bo_reserve
>
> ...are signed. While it works for the latter since the check is
> done on != 0 it doesn't work for the former since we check <= 0.
>
> [How]
>
> Make 'r' an int in commit planes so we're not doing any unsigned/signed
> conversion here in the first place.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index becd8cb3aab6..722f863ce4a4 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5332,7 +5332,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>   				    struct drm_crtc *pcrtc,
>   				    bool wait_for_vblank)
>   {
> -	uint32_t i, r;
> +	uint32_t i;
>   	uint64_t timestamp_ns;
>   	struct drm_plane *plane;
>   	struct drm_plane_state *old_plane_state, *new_plane_state;
> @@ -5342,7 +5342,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>   	struct dm_crtc_state *acrtc_state = to_dm_crtc_state(new_pcrtc_state);
>   	struct dm_crtc_state *dm_old_crtc_state =
>   			to_dm_crtc_state(drm_atomic_get_old_crtc_state(state, pcrtc));
> -	int planes_count = 0, vpos, hpos;
> +	int r, planes_count = 0, vpos, hpos;
>   	unsigned long flags;
>   	struct amdgpu_bo *abo;
>   	uint64_t tiling_flags;
Am 02.05.19 um 15:08 schrieb Christian König:
> Am 02.05.19 um 15:03 schrieb Nicholas Kazlauskas:
>> [Why]
>>
>> The type of 'r' is uint32_t and the return codes for both:
>>
>> - reservation_object_wait_timeout_rcu
>> - amdgpu_bo_reserve
>>
>> ...are signed. While it works for the latter since the check is
>> done on != 0 it doesn't work for the former since we check <= 0.
>>
>> [How]
>>
>> Make 'r' an int in commit planes so we're not doing any unsigned/signed
>> conversion here in the first place.
>>
>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>

Oh, wait a second. Shouldn't this even be a long instead of an int?

Christian.

>
>> ---
>>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> index becd8cb3aab6..722f863ce4a4 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> @@ -5332,7 +5332,7 @@ static void amdgpu_dm_commit_planes(struct 
>> drm_atomic_state *state,
>>                       struct drm_crtc *pcrtc,
>>                       bool wait_for_vblank)
>>   {
>> -    uint32_t i, r;
>> +    uint32_t i;
>>       uint64_t timestamp_ns;
>>       struct drm_plane *plane;
>>       struct drm_plane_state *old_plane_state, *new_plane_state;
>> @@ -5342,7 +5342,7 @@ static void amdgpu_dm_commit_planes(struct 
>> drm_atomic_state *state,
>>       struct dm_crtc_state *acrtc_state = 
>> to_dm_crtc_state(new_pcrtc_state);
>>       struct dm_crtc_state *dm_old_crtc_state =
>> to_dm_crtc_state(drm_atomic_get_old_crtc_state(state, pcrtc));
>> -    int planes_count = 0, vpos, hpos;
>> +    int r, planes_count = 0, vpos, hpos;
>>       unsigned long flags;
>>       struct amdgpu_bo *abo;
>>       uint64_t tiling_flags;
>
On 5/2/19 9:09 AM, Christian König wrote:
> 

> Am 02.05.19 um 15:08 schrieb Christian König:

>> Am 02.05.19 um 15:03 schrieb Nicholas Kazlauskas:

>>> [Why]

>>>

>>> The type of 'r' is uint32_t and the return codes for both:

>>>

>>> - reservation_object_wait_timeout_rcu

>>> - amdgpu_bo_reserve

>>>

>>> ...are signed. While it works for the latter since the check is

>>> done on != 0 it doesn't work for the former since we check <= 0.

>>>

>>> [How]

>>>

>>> Make 'r' an int in commit planes so we're not doing any unsigned/signed

>>> conversion here in the first place.

>>>

>>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

>>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>

>>

>> Reviewed-by: Christian König <christian.koenig@amd.com>

> 

> Oh, wait a second. Shouldn't this even be a long instead of an int?

> 

> Christian.


To be fully correct on all architectures I suppose that's true. I'll 
repost it with that fixed. Thanks.

Nicholas Kazlauskas

> 

>>

>>> ---

>>>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--

>>>   1 file changed, 2 insertions(+), 2 deletions(-)

>>>

>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

>>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

>>> index becd8cb3aab6..722f863ce4a4 100644

>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

>>> @@ -5332,7 +5332,7 @@ static void amdgpu_dm_commit_planes(struct

>>> drm_atomic_state *state,

>>>                       struct drm_crtc *pcrtc,

>>>                       bool wait_for_vblank)

>>>   {

>>> -    uint32_t i, r;

>>> +    uint32_t i;

>>>       uint64_t timestamp_ns;

>>>       struct drm_plane *plane;

>>>       struct drm_plane_state *old_plane_state, *new_plane_state;

>>> @@ -5342,7 +5342,7 @@ static void amdgpu_dm_commit_planes(struct

>>> drm_atomic_state *state,

>>>       struct dm_crtc_state *acrtc_state =

>>> to_dm_crtc_state(new_pcrtc_state);

>>>       struct dm_crtc_state *dm_old_crtc_state =

>>> to_dm_crtc_state(drm_atomic_get_old_crtc_state(state, pcrtc));

>>> -    int planes_count = 0, vpos, hpos;

>>> +    int r, planes_count = 0, vpos, hpos;

>>>       unsigned long flags;

>>>       struct amdgpu_bo *abo;

>>>       uint64_t tiling_flags;

>>

>