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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/29/19 2:03 PM, Dan Carpenter wrote:
> 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@xxxxxxx>
>> ---
>>   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)
>> 		fence = sched->ops->run_job(s_job);
>>   
>>   		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));
> I feel like I should explain better.  It's generally bad to mix NULL and
> error pointers.  The situation where you would do it is when NULL is a
> special case of success.  A typical situation is you request a feature,
> like maybe logging for example:
>
> 	p = get_logger();
>
> If there isn't enough memory then get_logger() returns ERR_PTR(-ENOMEM);
> but if the user has disabled logging then we can't return a valid
> pointer but it's also not an error so we return NULL.  It's a special
> case of success.
>
> In this situation sched->ops->run_job(s_job); appears to only ever
> return NULL and it's not a special case of success, it's a regular old
> error.  I guess we are transitioning from returning NULL to returning
> error pointers?


No, check patch 'drm/amdgpu: If amdgpu_ib_schedule fails return back the 
error.' , amdgpu_job_run will pack an actual error code into ERR_PTR

Andrey


>
> So we should just do something like:
>
> 	fence = sched->ops->run_job(s_job);
>
> 	/* FIXME: Oct 2019: Remove this code when fence can't be NULL. */
> 	if (!fence)
> 		fence = ERR_PTR(-EINVAL);
>
> 	if (IS_ERR(fence)) {
> 		...
>
> regards,
> dan carpenter
>
_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux