drm/amdgpu: fix the logic to validate fpriv and root bo
Subsystems (2)
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.
Reported-by kernel test robot <[email protected]>
Signed-off-by Sunil Khatri <[email protected]>
--- 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
@@ -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
Christian König
maintainerQuoted 11 lines · Sunil Khatri
Fix the smatch warning,
smatch warnings:drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c:2146amdgpu_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 <[email protected]>Signed-off-by Sunil Khatri <[email protected]>
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@@ -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);