allocated_doorbell has an option to set the doorbell id
to a specific value (used by CRIU). This value was not
bounds checked.

Check to confirm it's less than KFD_MAX_NUM_OF_QUEUES_PER_PROCESS.

Signed-off-by: David Francis <[email protected]>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 2e6923528342..b4cc74138f1e 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -612,6 +612,9 @@ static int allocate_doorbell(struct qcm_process_device *qpd,
        } else {
                /* For CP queues on SOC15 */
                if (restore_id) {
+                       if (*restore_id >= KFD_MAX_NUM_OF_QUEUES_PER_PROCESS)
+                               return -EINVAL;
+
                        /* make sure that ID is free  */
                        if (__test_and_set_bit(*restore_id, 
qpd->doorbell_bitmap))
                                return -EINVAL;
-- 
2.34.1

Reply via email to