Skip to contentSkip to conversation

drm/amdgpu: ensure device_list is initialised before calling list_add_tail

PATCH In review Colin King 2 participants 2 messages Apr 10, 2020 – Apr 11, 2020

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/amdgpu: ensure device_list is initialised before calling list_add_tail

From: Colin Ian King <[email protected]>

Currently the call to list_add_tail will access an the uninitalised device_list.prev. Fix this by ensuring device_list is initialized before adding items to it.

Addresses-Coverity: ("Uninitialized pointer read")

Fixes b3dbd6d3ec49 ("drm/amdgpu: resolve mGPU RAS query instability")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
index b0aa4e1ed4df..caa4969bd46f 100644
@@ -1447,6 +1447,7 @@ static void amdgpu_ras_do_recovery(struct work_struct *work)
 	if  (hive && adev->gmc.xgmi.num_physical_nodes > 1) {
 		device_list_handle = &hive->device_list;
 	} else {
+		INIT_LIST_HEAD(&device_list);
 		list_add_tail(&adev->gmc.xgmi.head, &device_list);
 		device_list_handle = &device_list;
 	}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 7 lines · Colin King

From: Colin Ian King <[email protected]>

Currently the call to list_add_tail will access an the uninitalised device_list.prev. Fix this by ensuring device_list is initialized before adding items to it.

Addresses-Coverity: ("Uninitialized pointer read")

That weird, I see that his is already initialized unconditionally here -
https://elixir.bootlin.com/linux/v5.6.3/source/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c#L4022

Andrey

Quoted 18 lines
Fixes b3dbd6d3ec49 ("drm/amdgpu: resolve mGPU RAS query instability")
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
index b0aa4e1ed4df..caa4969bd46f 100644
@@ -1447,6 +1447,7 @@ static void amdgpu_ras_do_recovery(struct work_struct *work)
  	if  (hive && adev->gmc.xgmi.num_physical_nodes > 1) {
  		device_list_handle = &hive->device_list;
  	} else {
+		INIT_LIST_HEAD(&device_list);
  		list_add_tail(&adev->gmc.xgmi.head, &device_list);
  		device_list_handle = &device_list;
  	}