[bug report] drm/amdgpu: optimize the gpu reset for XGMI setup V2
Dan Carpenter
dan.carpenter at oracle.com
Fri Apr 24 10:27:39 UTC 2020
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
More information about the amd-gfx
mailing list