*/
                pr_warn("%s: called with uninitialized scheduler\n", __func__);
        } else if (num_sched_list) {
-               /* The "priority" of an entity cannot exceed the number
-                * of run-queues of a scheduler.
+               /* The "priority" of an entity cannot exceed the number of run-queues of a
+                * scheduler. Protect against num_rqs being 0, by converting to signed.
                 */
-               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];
        }