drm/amdkfd: Add upper bound check for num_of_nodes
in kfd_ioctl_get_process_apertures_new.

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

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 1db565442c48..91f807c9e553 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -776,6 +776,9 @@ static int kfd_ioctl_get_process_apertures_new(struct file 
*filp,
                goto out_unlock;
        }
 
+       if (args->num_of_nodes > p->n_pdds)
+               return -EINVAL;
+
        /* Fill in process-aperture information for all available
         * nodes, but not more than args->num_of_nodes as that is
         * the amount of memory allocated by user
-- 
2.34.1

Reply via email to