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

Dan Carpenter dan.carpenter at oracle.com
Tue Oct 29 17:51:48 UTC 2019


On Tue, Oct 29, 2019 at 11:04:44AM -0400, Andrey Grodzovsky wrote:
> Fix a static code checker warning.
> 
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky at amd.com>
> ---
>  drivers/gpu/drm/scheduler/sched_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index f39b97e..898b0c9 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -497,7 +497,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)
>  
>  		if (IS_ERR_OR_NULL(fence)) {
>  			s_job->s_fence->parent = NULL;
> -			dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
> +			dma_fence_set_error(&s_fence->finished, PTR_ERR_OR_ZERO(fence));

This will silence the static checker warning, but it will still trigger
a WARN_ON().  And it sort of has inspired me to generate a new warning
because that's not how PTR_ERR_OR_ZERO() is supposed to be used.  :P

PTR_ERR_OR_ZERO() is short hand for this situation:

-	if (IS_ERR(fence))
-		return PTR_ERR(fence);
-	return 0;
+	return PTR_ERR_OR_ZERO(fence);

regards,
dan carpenter




More information about the amd-gfx mailing list