[PATCH] drm/sched: Fix bounds limiting when given a malformed entity
Luben Tuikov
ltuikov89 at gmail.com
Thu Nov 23 12:24:23 UTC 2023
If we're given a malformed entity in drm_sched_entity_init()--shouldn't
happen, but we verify--with out-of-bounds priority value, we set it to an
allowed value. Fix the expression which sets this limit.
Signed-off-by: Luben Tuikov <ltuikov89 at gmail.com>
Fixes: 56e449603f0ac5 ("drm/sched: Convert the GPU scheduler to variable number of run-queues")
---
drivers/gpu/drm/scheduler/sched_entity.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index 4d42b1e4daa67f..20c9c561843ce1 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -84,9 +84,12 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
/* The "priority" of an entity cannot exceed the number
* of run-queues of a scheduler.
*/
- if (entity->priority >= sched_list[0]->num_rqs)
- entity->priority = max_t(u32, sched_list[0]->num_rqs,
- DRM_SCHED_PRIORITY_MIN);
+ if (entity->priority >= sched_list[0]->num_rqs) {
+ drm_err(sched_list[0], "entity with out-of-bounds priority:%u num_rqs:%u\n",
+ entity->priority, sched_list[0]->num_rqs);
+ entity->priority = max_t(s32, (s32) sched_list[0]->num_rqs - 1,
+ (s32) DRM_SCHED_PRIORITY_MIN);
+ }
entity->rq = sched_list[0]->sched_rq[entity->priority];
}
base-commit: b3c5a7de9aeb51cb19160f3f61343ed87487abde
--
2.43.0
More information about the dri-devel
mailing list