mirror of
https://github.com/openbsd/src.git
synced 2026-06-18 07:13:36 +02:00
drm/amdkfd: Add upper bound check for num_of_nodes
From Alysa Liu 44d5a450c04d3d734c13a03561c3131020d66edf in linux-6.18.y/6.18.32 74b73fa56a395d46745e4f245225963e9f8be7f1 in mainline linux
This commit is contained in:
@@ -763,6 +763,9 @@ static int kfd_ioctl_get_process_apertures_new(struct file *filp,
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
if (args->num_of_nodes > kfd_topology_get_num_devices())
|
||||
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
|
||||
|
||||
@@ -1175,6 +1175,7 @@ static inline struct kfd_node *kfd_node_by_irq_ids(struct amdgpu_device *adev,
|
||||
return NULL;
|
||||
}
|
||||
int kfd_topology_enum_kfd_devices(uint8_t idx, struct kfd_node **kdev);
|
||||
uint32_t kfd_topology_get_num_devices(void);
|
||||
int kfd_numa_node_to_apic_id(int numa_node_id);
|
||||
|
||||
/* Interrupts */
|
||||
|
||||
@@ -2295,6 +2295,17 @@ int kfd_topology_remove_device(struct kfd_node *gpu)
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t kfd_topology_get_num_devices(void)
|
||||
{
|
||||
uint32_t num_devices;
|
||||
|
||||
down_read(&topology_lock);
|
||||
num_devices = sys_props.num_devices;
|
||||
up_read(&topology_lock);
|
||||
|
||||
return num_devices;
|
||||
}
|
||||
|
||||
/* kfd_topology_enum_kfd_devices - Enumerate through all devices in KFD
|
||||
* topology. If GPU device is found @idx, then valid kfd_dev pointer is
|
||||
* returned through @kdev
|
||||
|
||||
Reference in New Issue
Block a user