Skip to contentSkip to conversation

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

PATCH In review Sunil Khatri 2 participants 2 messages Jul 9, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index e49890a23ef6..63cd790b1d7b 100644
@@ -2143,7 +2143,7 @@ static int amdgpu_pt_info_read(struct seq_file *m, void *unused)
 		return -EINVAL;
 
 	fpriv = file->driver_priv;
-	if (!fpriv && !fpriv->vm.root.bo)
+	if (!fpriv || !fpriv->vm.root.bo)
 		return -ENODEV;
 
 	root_bo = amdgpu_bo_ref(fpriv->vm.root.bo);
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 11 lines · Sunil Khatri

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.

Reviewed and pushed to drm-misc-next.

Regards,
Christian.

Quoted 17 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index e49890a23ef6..63cd790b1d7b 100644
@@ -2143,7 +2143,7 @@ static int amdgpu_pt_info_read(struct seq_file *m, void *unused)
 		return -EINVAL;
 
 	fpriv = file->driver_priv;
-	if (!fpriv && !fpriv->vm.root.bo)
+	if (!fpriv || !fpriv->vm.root.bo)
 		return -ENODEV;
 
 	root_bo = amdgpu_bo_ref(fpriv->vm.root.bo);