DragonFlyBSD Kernel Audit
DF-2205 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/amd/amdgpu/amdgpu_xgmi.c b/sys/dev/drm/amd/amdgpu/amdgpu_xgmi.c
index 0000000..1111111 100644
--- a/sys/dev/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/sys/dev/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -88,6 +88,17 @@
 
 	ret = psp_xgmi_get_topology_info(&adev->psp, count, tmp_topology);
 	if (ret) {
+		/*
+		 * DF-2205: We added adev to hive->device_list above before
+		 * this call succeeded; if we leave it linked on error, the
+		 * hive permanently contains an entry whose topology was
+		 * never fetched/set, and the next amdgpu_xgmi_add_device()
+		 * for any other node will copy its stale device_id into
+		 * tmp_topology and try to drive psp_xgmi_set_topology_info
+		 * across the half-baked node.  Undo the linkage first.
+		 */
+		list_del(&adev->gmc.xgmi.head);
+		INIT_LIST_HEAD(&adev->gmc.xgmi.head);
 		dev_err(adev->dev,
 			"XGMI: Get topology failure on device %llx, hive %llx, ret %d",
 			adev->gmc.xgmi.device_id,