[bug report] drm/amdkfd: Add DMABuf import functionality

Dan Carpenter dan.carpenter at oracle.com
Fri Dec 14 15:01:13 UTC 2018


Hello Felix Kuehling,

The patch 1dde0ea95b78: "drm/amdkfd: Add DMABuf import functionality"
from Nov 20, 2018, leads to the following static checker warning:

	drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_chardev.c:1643 kfd_ioctl_import_dmabuf()
	error: 'dmabuf' dereferencing possible ERR_PTR()

drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_chardev.c
  1615  static int kfd_ioctl_import_dmabuf(struct file *filep,
  1616                                     struct kfd_process *p, void *data)
  1617  {
  1618          struct kfd_ioctl_import_dmabuf_args *args = data;
  1619          struct kfd_process_device *pdd;
  1620          struct dma_buf *dmabuf;
  1621          struct kfd_dev *dev;
  1622          int idr_handle;
  1623          uint64_t size;
  1624          void *mem;
  1625          int r;
  1626  
  1627          dev = kfd_device_by_id(args->gpu_id);
  1628          if (!dev)
  1629                  return -EINVAL;
  1630  
  1631          dmabuf = dma_buf_get(args->dmabuf_fd);
                         ^^^^^^^^^^^^
returns error pointers and maybe NULL as well?

  1632          if (!dmabuf)
  1633                  return -EINVAL;
  1634  
  1635          mutex_lock(&p->mutex);
  1636  
  1637          pdd = kfd_bind_process_to_device(dev, p);
  1638          if (IS_ERR(pdd)) {
  1639                  r = PTR_ERR(pdd);
  1640                  goto err_unlock;
  1641          }
  1642  
  1643          r = amdgpu_amdkfd_gpuvm_import_dmabuf(dev->kgd, dmabuf,
                                                                ^^^^^^
Dereferenced inside function.

  1644                                                args->va_addr, pdd->vm,
  1645                                                (struct kgd_mem **)&mem, &size,
  1646                                                NULL);
  1647          if (r)
  1648                  goto err_unlock;

regards,
dan carpenter


More information about the amd-gfx mailing list