All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Jerry (Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: "Christian König" <christian.koenig-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/scheduler: add NULL pointer check for run queue
Date: Mon, 16 Jul 2018 17:17:28 +0800	[thread overview]
Message-ID: <5B4C62A8.7020005@amd.com> (raw)
In-Reply-To: <e2dc7604-e706-c646-bf98-c058d847695e-5C7GfCeVMHo@public.gmane.org>

On 07/16/2018 05:11 PM, Christian König wrote:
> Am 16.07.2018 um 11:01 schrieb Zhang, Jerry (Junwei):
>> On 07/16/2018 04:31 PM, Christian König wrote:
>>> Am 16.07.2018 um 04:59 schrieb Junwei Zhang:
>>>> To check rq pointer before adding entity into it.
>>>> That avoids NULL pointer access in some case.
>>>>
>>>> Suggested-by: Christian König <christian.koenig@amd.com>
>>>> Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com>
>>>> ---
>>>>   drivers/gpu/drm/scheduler/gpu_scheduler.c | 4 ++++
>>>>   1 file changed, 4 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c
>>>> index 16bf446..5e5268d 100644
>>>> --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c
>>>> +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c
>>>> @@ -91,6 +91,10 @@ static void drm_sched_rq_add_entity(struct drm_sched_rq *rq,
>>>>   {
>>>>       if (!list_empty(&entity->list))
>>>>           return;
>>>> +    if (!rq) {
>>>> +        DRM_ERROR("rq is NULL!\n");
>>>> +        return;
>>>> +    }
>>>
>>> Better put that into drm_sched_entity_push_job(), e.g. something like:
>>
>> Considered that as well.
>> Just be afraid of someone else could call it in another place without rq checking in the future.
>
> Well that's exactly the reason why I wanted to have the check in drm_sched_rq_add_entity().
>
> Calling drm_sched_rq_add_entity() will a NULL rq is illegal and that should be avoided in the caller instead of more or less silently dropped in the function.

Fine, to expose the error in place explicitly.

Regards,
Jerry

>
> Regards,
> Christian.
>
>>
>> Regards,
>> Jerry
>>
>>>
>>> /* first job wakes up scheduler */
>>> if (first) {
>>>      /* Add the entity to the run queue */
>>>      spin_lock(&entity->rq_lock);
>>>      if (!entity->rq) {
>>>          DRM_ERROR("Trying to push to killed entity!\n");
>>> ....
>>>
>>> Regards,
>>> Christian.
>>>
>>>>       spin_lock(&rq->lock);
>>>>       list_add_tail(&entity->list, &rq->entities);
>>>>       spin_unlock(&rq->lock);
>>>
>
> _______________________________________________
> 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

      parent reply	other threads:[~2018-07-16  9:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16  2:59 [PATCH] drm/scheduler: add NULL pointer check for run queue Junwei Zhang
     [not found] ` <1531709980-21298-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
2018-07-16  8:31   ` Christian König
     [not found]     ` <045ffcc7-9b9a-2534-9ebe-295e18ce62e7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-07-16  9:01       ` Zhang, Jerry (Junwei)
     [not found]         ` <5B4C5EFD.60301-5C7GfCeVMHo@public.gmane.org>
2018-07-16  9:11           ` Christian König
     [not found]             ` <e2dc7604-e706-c646-bf98-c058d847695e-5C7GfCeVMHo@public.gmane.org>
2018-07-16  9:17               ` Zhang, Jerry (Junwei) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5B4C62A8.7020005@amd.com \
    --to=jerry.zhang-5c7gfcevmho@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.