Skip to contentSkip to conversation

drm/amdgpu: guard against failed kfd node init

PATCH New Yiqing Yao 1 participant 1 message Sep 28

Subsystems (3)
lore
Share & tools
lore

Yiqing Yao

author
#0 lore raw

PATCH 1/1 drm/amdgpu: guard against failed kfd node init

before kfd_dev_unmap_mapping_range check ptr to avoid null pointer
from failed or incomplete kfd node init.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +6 -1
index 09feb45584bab..7256ec1290bcd 100644
@@ -330,11 +330,16 @@ void amdgpu_amdkfd_clear_kfd_mapping(struct amdgpu_device *adev)
 	struct kfd_dev *kfd = adev->kfd.dev;
 	unsigned int i;
 
-	if (!kfd)
+	/* kfd->num_nodes is set before kfd->nodes[] is populated, so a failed
+	 * or incomplete kgd2kfd_device_init() leaves NULL node pointers behind
+	 */
+	if (!kfd || !adev->kfd.init_complete)
 		return;
 
 	for (i = 0; i < kfd->num_nodes; i++) {
 		struct kfd_node *node = kfd->nodes[i];
+		if (!node)
+			continue;
 
 		kfd_dev_unmap_mapping_range(KFD_MMAP_TYPE_DOORBELL |
 					    KFD_MMAP_GPU_ID(node->id),
Signature · 1 line
2.34.1