diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2024-01-29 01:49:29 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2024-01-29 01:49:29 +0000 |
commit | 7f6e1e437230720c38373dd28a53be1072f8beb1 (patch) | |
tree | dbb6f2fbe5eb75012d7fab053f0a5cb7b7852d40 /sys | |
parent | 3148ee4db8449469d25566b82a676d8fa6eda510 (diff) |
drm/amdkfd: Confirm list is non-empty before utilizing list_first_entry in kfd_topology.c
From Srinivasan Shanmugam
5024cce888e11e5688f77df81db9e14828495d64 in linux-6.6.y/6.6.14
499839eca34ad62d43025ec0b46b80e77065f6d8 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/amd/amdkfd/kfd_topology.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_topology.c b/sys/dev/pci/drm/amd/amdkfd/kfd_topology.c index c8c75ff7cea..6e75e8fa18b 100644 --- a/sys/dev/pci/drm/amd/amdkfd/kfd_topology.c +++ b/sys/dev/pci/drm/amd/amdkfd/kfd_topology.c @@ -1342,10 +1342,11 @@ static int kfd_create_indirect_link_prop(struct kfd_topology_device *kdev, int g num_cpu++; } + if (list_empty(&kdev->io_link_props)) + return -ENODATA; + gpu_link = list_first_entry(&kdev->io_link_props, - struct kfd_iolink_properties, list); - if (!gpu_link) - return -ENOMEM; + struct kfd_iolink_properties, list); for (i = 0; i < num_cpu; i++) { /* CPU <--> GPU */ @@ -1423,15 +1424,17 @@ static int kfd_add_peer_prop(struct kfd_topology_device *kdev, peer->gpu->adev)) return ret; + if (list_empty(&kdev->io_link_props)) + return -ENODATA; + iolink1 = list_first_entry(&kdev->io_link_props, - struct kfd_iolink_properties, list); - if (!iolink1) - return -ENOMEM; + struct kfd_iolink_properties, list); + + if (list_empty(&peer->io_link_props)) + return -ENODATA; iolink2 = list_first_entry(&peer->io_link_props, - struct kfd_iolink_properties, list); - if (!iolink2) - return -ENOMEM; + struct kfd_iolink_properties, list); props = kfd_alloc_struct(props); if (!props) |