drm/scheduler: add NULL pointer check for run queue
Subsystems (3)
PATCH 1/1 drm/scheduler: add NULL pointer check for run queue
To check rq pointer before adding entity into it.
That avoids NULL pointer access in some case.
--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/scheduler/gpu_scheduler.c +4 -0
@@ -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 ; + }spin_lock (&rq->lock);list_add_tail (&entity->list, &rq->entities);spin_unlock (&rq->lock);
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1531709980-21298-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org
Am 16.07.2018 um 04:59 schrieb Junwei Zhang:
Quoted 14 lines
To check rq pointer before adding entity into it.
That avoids NULL pointer access in some case.Suggested-by Christian König <[email protected]>Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/scheduler/gpu_scheduler.c +0
-0
drivers/gpu/drm/scheduler/gpu_scheduler.c static void drm_sched_rq_add_entity(struct drm_sched_rq *rq, · line 97
Quoted 7 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +4
-0@@ -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:
/* 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.
drivers/gpu/drm/scheduler/gpu_scheduler.c static void drm_sched_rq_add_entity(struct drm_sched_rq *rq, · line 100
Quoted 3 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +0
-0spin_lock (&rq->lock);list_add_tail (&entity->list, &rq->entities);spin_unlock (&rq->lock);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 045ffcc7-9b9a-2534-9ebe-295e18ce62e7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 10 lines · Christian König
Am 16.07.2018 um 04:59 schrieb Junwei Zhang:
Quoted 9 lines
To check rq pointer before adding entity into it.
That avoids NULL pointer access in some case.Suggested-by Christian König <[email protected]>Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 14 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c static void drm_sched_rq_add_entity(struct drm_sched_rq *rq, · line 97
Quoted 12 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +4
-0@@ -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.
Regards,
Jerry
Quoted 7 lines
/* 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");
Quoted 9 lines
....
Regards,
Christian.Quoted 3 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +0
-0spin_lock (&rq->lock);list_add_tail (&entity->list, &rq->entities);spin_unlock (&rq->lock);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Am 16.07.2018 um 11:01 schrieb Zhang, Jerry (Junwei):
Quoted 27 lines · Christian König
Quoted 10 lines
Am 16.07.2018 um 04:59 schrieb Junwei Zhang:
Quoted 9 lines
To check rq pointer before adding entity into it.
That avoids NULL pointer access in some case.Suggested-by Christian König <[email protected]>Signed-off-by Junwei Zhang <[email protected]>---
drivers/gpu/drm/scheduler/gpu_scheduler.c| 4 ++++1 file changed, 4 insertions(+)Quoted 15 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c static void drm_sched_rq_add_entity(struct · line 98
Quoted 13 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +4
-0@@ -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:
Quoted 2 lines
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.
Regards,
Christian.
Quoted 20 lines
Regards,
JerryQuoted 16 lines
/* 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.Quoted 3 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +0
-0spin_lock(&rq->lock); list_add_tail(&entity->list, &rq->entities);
spin_unlock(&rq->lock);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): e2dc7604-e706-c646-bf98-c058d847695e-5C7GfCeVMHo@public.gmane.org
Quoted 27 lines · Christian König
Am 16.07.2018 um 11:01 schrieb Zhang, Jerry (Junwei):
Quoted 26 lines · Christian König
Quoted 24 lines
Am 16.07.2018 um 04:59 schrieb Junwei Zhang:
Quoted 14 lines
To check rq pointer before adding entity into it.
That avoids NULL pointer access in some case.Suggested-by Christian König <[email protected]>Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/scheduler/gpu_scheduler.c +0
-0drivers/gpu/drm/scheduler/gpu_scheduler.c static void drm_sched_rq_add_entity(struct drm_sched_rq *rq, · line 97
Quoted 7 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +4
-0@@ -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:
Quoted 6 lines
Quoted 2 lines
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
Quoted 25 lines
Regards,
Christian.Quoted 20 lines
Regards,
JerryQuoted 16 lines
/* 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.Quoted 3 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +0
-0spin_lock (&rq->lock);list_add_tail (&entity->list, &rq->entities);spin_unlock (&rq->lock);
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx