The valid amdkfd event ids go from 0 to KFD_SIGNAL_EVENT_LIMIT - 1.

During CRIU restore, ensure that the provided event ids are
in that range.

(The CRIU input is a uint32_t, so it can't be negative, but check
just for the sake of the function being clear)

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

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
index e9be798c0a2b..2c63dfe8e189 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
@@ -107,6 +107,9 @@ static int allocate_event_notification_slot(struct 
kfd_process *p,
        }
 
        if (restore_id) {
+               if (*restore_id <= 0 || *restore_id >= KFD_SIGNAL_EVENT_LIMIT)
+                       return -EINVAL;
+
                id = idr_alloc(&p->event_idr, ev, *restore_id, *restore_id + 1,
                                GFP_KERNEL);
        } else {
-- 
2.34.1

Reply via email to