diff mbox series

[v2] drm/sched: Fix passing zero to 'PTR_ERR' warning

Message ID 1572372468-20569-1-git-send-email-andrey.grodzovsky@amd.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/sched: Fix passing zero to 'PTR_ERR' warning | expand

Commit Message

Andrey Grodzovsky Oct. 29, 2019, 6:07 p.m. UTC
Fix a static code checker warning.

v2: Drop PTR_ERR_OR_ZERO.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/scheduler/sched_main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Emily Deng Nov. 4, 2019, 3:37 a.m. UTC | #1
Reviewed-by: Emily Deng <Emily.Deng@amd.com>

>-----Original Message-----
>From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of
>Andrey Grodzovsky
>Sent: Wednesday, October 30, 2019 2:08 AM
>To: dan.carpenter@oracle.com
>Cc: Grodzovsky, Andrey <Andrey.Grodzovsky@amd.com>; amd-
>gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org
>Subject: [PATCH v2] drm/sched: Fix passing zero to 'PTR_ERR' warning
>
>Fix a static code checker warning.
>
>v2: Drop PTR_ERR_OR_ZERO.
>
>Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
>---
> drivers/gpu/drm/scheduler/sched_main.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpu/drm/scheduler/sched_main.c
>b/drivers/gpu/drm/scheduler/sched_main.c
>index f39b97e..dba4390 100644
>--- a/drivers/gpu/drm/scheduler/sched_main.c
>+++ b/drivers/gpu/drm/scheduler/sched_main.c
>@@ -496,8 +496,10 @@ void drm_sched_resubmit_jobs(struct
>drm_gpu_scheduler *sched)
> 		fence = sched->ops->run_job(s_job);
>
> 		if (IS_ERR_OR_NULL(fence)) {
>+			if (IS_ERR(fence))
>+				dma_fence_set_error(&s_fence->finished,
>PTR_ERR(fence));
>+
> 			s_job->s_fence->parent = NULL;
>-			dma_fence_set_error(&s_fence->finished,
>PTR_ERR(fence));
> 		} else {
> 			s_job->s_fence->parent = fence;
> 		}
>@@ -741,8 +743,9 @@ static int drm_sched_main(void *param)
> 					  r);
> 			dma_fence_put(fence);
> 		} else {
>+			if (IS_ERR(fence))
>+				dma_fence_set_error(&s_fence->finished,
>PTR_ERR(fence));
>
>-			dma_fence_set_error(&s_fence->finished,
>PTR_ERR(fence));
> 			drm_sched_process_job(NULL, &sched_job->cb);
> 		}
>
>--
>2.7.4
>
>_______________________________________________
>amd-gfx mailing list
>amd-gfx@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König Nov. 4, 2019, 12:15 p.m. UTC | #2
Reviewed-by: Christian König <christian.koenig@amd.com>

Am 04.11.19 um 04:37 schrieb Deng, Emily:
> Reviewed-by: Emily Deng <Emily.Deng@amd.com>
>
>> -----Original Message-----
>> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of
>> Andrey Grodzovsky
>> Sent: Wednesday, October 30, 2019 2:08 AM
>> To: dan.carpenter@oracle.com
>> Cc: Grodzovsky, Andrey <Andrey.Grodzovsky@amd.com>; amd-
>> gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org
>> Subject: [PATCH v2] drm/sched: Fix passing zero to 'PTR_ERR' warning
>>
>> Fix a static code checker warning.
>>
>> v2: Drop PTR_ERR_OR_ZERO.
>>
>> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
>> ---
>> drivers/gpu/drm/scheduler/sched_main.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/scheduler/sched_main.c
>> b/drivers/gpu/drm/scheduler/sched_main.c
>> index f39b97e..dba4390 100644
>> --- a/drivers/gpu/drm/scheduler/sched_main.c
>> +++ b/drivers/gpu/drm/scheduler/sched_main.c
>> @@ -496,8 +496,10 @@ void drm_sched_resubmit_jobs(struct
>> drm_gpu_scheduler *sched)
>> 		fence = sched->ops->run_job(s_job);
>>
>> 		if (IS_ERR_OR_NULL(fence)) {
>> +			if (IS_ERR(fence))
>> +				dma_fence_set_error(&s_fence->finished,
>> PTR_ERR(fence));
>> +
>> 			s_job->s_fence->parent = NULL;
>> -			dma_fence_set_error(&s_fence->finished,
>> PTR_ERR(fence));
>> 		} else {
>> 			s_job->s_fence->parent = fence;
>> 		}
>> @@ -741,8 +743,9 @@ static int drm_sched_main(void *param)
>> 					  r);
>> 			dma_fence_put(fence);
>> 		} else {
>> +			if (IS_ERR(fence))
>> +				dma_fence_set_error(&s_fence->finished,
>> PTR_ERR(fence));
>>
>> -			dma_fence_set_error(&s_fence->finished,
>> PTR_ERR(fence));
>> 			drm_sched_process_job(NULL, &sched_job->cb);
>> 		}
>>
>> --
>> 2.7.4
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Boris Brezillon Nov. 29, 2019, 3:04 p.m. UTC | #3
On Tue, 29 Oct 2019 14:07:48 -0400
Andrey Grodzovsky <andrey.grodzovsky@amd.com> wrote:

> Fix a static code checker warning.
> 
> v2: Drop PTR_ERR_OR_ZERO.
> 
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
> ---
>  drivers/gpu/drm/scheduler/sched_main.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index f39b97e..dba4390 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -496,8 +496,10 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)
>  		fence = sched->ops->run_job(s_job);
>  
>  		if (IS_ERR_OR_NULL(fence)) {
> +			if (IS_ERR(fence))
> +				dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
> +
>  			s_job->s_fence->parent = NULL;
> -			dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
>  		} else {
>  			s_job->s_fence->parent = fence;
>  		}

Don't know if this patch has already been applied, but we can get rid of
the extra indentation level by doing:

		if (IS_ERR(fence)) {
			dma_fence_set_error(&s_fence->finished,
					    PTR_ERR(fence));
			fence = NULL;
		}

		s_job->s_fence->parent = fence;
diff mbox series

Patch

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index f39b97e..dba4390 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -496,8 +496,10 @@  void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)
 		fence = sched->ops->run_job(s_job);
 
 		if (IS_ERR_OR_NULL(fence)) {
+			if (IS_ERR(fence))
+				dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
+
 			s_job->s_fence->parent = NULL;
-			dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
 		} else {
 			s_job->s_fence->parent = fence;
 		}
@@ -741,8 +743,9 @@  static int drm_sched_main(void *param)
 					  r);
 			dma_fence_put(fence);
 		} else {
+			if (IS_ERR(fence))
+				dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
 
-			dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
 			drm_sched_process_job(NULL, &sched_job->cb);
 		}