Skip to contentSkip to conversation

drm/amdgpu: optimize the gpu reset for XGMI setup V2

bug report Dan Carpenter 1 participant 1 message Apr 24, 2020

lore
Share & tools
lore
#0 lore raw

Hello Evan Quan,

This is a semi-automatic email about new static checker warnings.

The patch 9e94d22c0085: "drm/amdgpu: optimize the gpu reset for XGMI setup V2" from Apr 16, 2020, leads to the following Smatch complaint:

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:4199 amdgpu_device_gpu_recover()
error: we previously assumed 'hive' could be null (see line 4196)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
4195 list_for_each_entry(tmp_adev, device_list_handle, gmc.xgmi.head) {

  4196			if (!amdgpu_device_lock_adev(tmp_adev, !hive)) {
                                                               ^^^^^

There are a ton of double negatives in this snippet.

Assume hive is NULL, then not NULL is true, so in amdgpu_device_lock_adev() we try to take the lock, and lets assume that fails. That's only path which returns false. In other words, we know that "hive" is NULL inside this condition.

4197 DRM_INFO("Bailing on TDR for s_job:%llx, as another already in progress",
4198 job ? job->base.id : -1);

  4199				mutex_unlock(&hive->hive_lock);
                                              ^^^^

NULL dereference.

4200 return 0;
4201 }

regards,
dan carpenter
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx