Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: fix the logic to validate fpriv and root bo

Fix the smatch warning,
smatch warnings:
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:2146 amdgpu_pt_info_read()
error: we previously assumed 'fpriv' could be null (see line 2146)

"if (!fpriv && !fpriv->vm.root.bo)", It has to be an OR condition
rather than an AND which makes an NULL dereference in case fpriv is NULL.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202507090525.9rDWGhz3-lkp@intel.com/
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Link: https://lore.kernel.org/r/20250709071618.591866-1-sunil.khatri@amd.com
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>

authored by

Sunil Khatri and committed by
Christian König
03d52360 8f9abaff

+1 -1
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
··· 2143 2143 return -EINVAL; 2144 2144 2145 2145 fpriv = file->driver_priv; 2146 - if (!fpriv && !fpriv->vm.root.bo) 2146 + if (!fpriv || !fpriv->vm.root.bo) 2147 2147 return -ENODEV; 2148 2148 2149 2149 root_bo = amdgpu_bo_ref(fpriv->vm.root.bo);