[PATCH] drm/amdgpu: fix the logic to validate fpriv and root bo
Christian König
christian.koenig at amd.com
Wed Jul 9 08:16:45 UTC 2025
On 09.07.25 09:16, Sunil Khatri wrote:
> 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 at intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202507090525.9rDWGhz3-lkp@intel.com/
> Signed-off-by: Sunil Khatri <sunil.khatri at amd.com>
Reviewed and pushed to drm-misc-next.
Regards,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index e49890a23ef6..63cd790b1d7b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -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);
More information about the amd-gfx
mailing list