In the event no device is found with the given proximity domain and
kfd_topology_device_by_proximity_domain_no_lock() returns a null device
immediately checking !peer_Dev->gpu will result in a null pointer
dereference.

Signed-off-by: Sunday Clement <[email protected]>
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
index 4a7180b46b71..6093d96c5892 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
@@ -2357,7 +2357,7 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,
        if (kdev->kfd->hive_id) {
                for (nid = 0; nid < proximity_domain; ++nid) {
                        peer_dev = 
kfd_topology_device_by_proximity_domain_no_lock(nid);
-                       if (!peer_dev->gpu)
+                       if (!peer_dev || !peer_dev->gpu)
                                continue;
                        if (peer_dev->gpu->kfd->hive_id != kdev->kfd->hive_id)
                                continue;
-- 
2.43.0

Reply via email to