drm/scheduler: add NULL pointer check for run queue (v2)
Subsystems (3)
PATCH 1/1 drm/scheduler: add NULL pointer check for run queue (v2)
To check rq pointer before adding entity into it.
That avoids NULL pointer access in some case.
v2: move the check to caller
--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/scheduler/gpu_scheduler.c +5 -0
@@ -547,6 +547,11 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job,if (first) {/* Add the entity to the run queue */ spin_lock (&entity->rq_lock); +if (!entity->rq) { +DRM_ERROR ("Trying to push to a killed entity\n" ); +spin_unlock (&entity->rq_lock); +return ; + }drm_sched_rq_add_entity (entity->rq, entity);spin_unlock (&entity->rq_lock);drm_sched_wakeup (sched);
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): 1531733034-22183-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org
Christian König
Reviewed-byAm 16.07.2018 um 11:23 schrieb Junwei Zhang:
Quoted 7 lines
To check rq pointer before adding entity into it.
That avoids NULL pointer access in some case.v2: move the check to caller
Suggested-by Christian König <[email protected]>Signed-off-by Junwei Zhang <[email protected]>
Quoted 10 lines
--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/scheduler/gpu_scheduler.c +0
-0@@ -547,6 +547,11 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job,if (first) {
drivers/gpu/drm/scheduler/gpu_scheduler.c void drm_sched_entity_push_job(struct drm_sched_job *sched_job, · line 557
Quoted 10 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +5
-0/* Add the entity to the run queue */ spin_lock (&entity->rq_lock); +if (!entity->rq) { +DRM_ERROR ("Trying to push to a killed entity\n" ); +spin_unlock (&entity->rq_lock); +return ; + }drm_sched_rq_add_entity (entity->rq, entity);spin_unlock (&entity->rq_lock);drm_sched_wakeup (sched);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 16 lines · Junwei Zhang
To check rq pointer before adding entity into it.
That avoids NULL pointer access in some case.v2: move the check to caller
Suggested-by Christian König <[email protected]>Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/scheduler/gpu_scheduler.c +0
-0
drivers/gpu/drm/scheduler/gpu_scheduler.c void drm_sched_entity_push_job(struct drm_sched_job *sched_job, · line 551
Quoted 5 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +2
-0@@ -547,6 +547,11 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job,if (first) {/* Add the entity to the run queue */ spin_lock (&entity->rq_lock); +if (!entity->rq) { +DRM_ERROR ("Trying to push to a killed entity\n" );
This could result in spamming dmesg with this error message. I suggest
if (WARN_ON_ONCE(!entity->rq)) {instead, no DRM_ERROR. That will produce a single warning with a backtrace.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ 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): e62a1051-00c9-99b2-dd83-d8f47e9038f4-otUistvHUpPR7s880joybQ@public.gmane.org
Quoted 12 lines · Michel Dänzer
Quoted 11 lines · Junwei Zhang
To check rq pointer before adding entity into it.
That avoids NULL pointer access in some case.v2: move the check to caller
Suggested-by Christian König <[email protected]>Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/scheduler/gpu_scheduler.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 12 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c void drm_sched_entity_push_job(struct drm_sched_job *sched_job, · line 551
Quoted 10 lines
drivers/gpu/drm/scheduler/gpu_scheduler.c +2
-0@@ -547,6 +547,11 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job,if (first) {/* Add the entity to the run queue */ spin_lock (&entity->rq_lock); +if (!entity->rq) { +DRM_ERROR ("Trying to push to a killed entity\n" );This could result in spamming dmesg with this error message. I suggest
Thanks for your comments.
Actually it will cause App or GPU hang, as the job is unexpected to push to a non-existing entity run queue. Now we're trying to predict that before kernel panic or BUG_ON.
Regards,
Jerry
Quoted 6 lines
if (WARN_ON_ONCE(!entity->rq)) {instead, no
DRM_ERROR. That will produce a single warning with a backtrace.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx