drm/amdkfd: Fix handling of return code of dma_buf_get
authorFelix Kuehling <Felix.Kuehling@amd.com>
Fri, 14 Dec 2018 16:57:02 +0000 (11:57 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 18 Dec 2018 22:39:11 +0000 (17:39 -0500)
On errors, dma_buf_get returns a negative error code, rather than NULL.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index 3623538baf6fc9c20dd79167826ded7d52acbc9e..db6f27fe3d5ae13b67010e89990170dc116432b8 100644 (file)
@@ -1629,8 +1629,8 @@ static int kfd_ioctl_import_dmabuf(struct file *filep,
                return -EINVAL;
 
        dmabuf = dma_buf_get(args->dmabuf_fd);
-       if (!dmabuf)
-               return -EINVAL;
+       if (IS_ERR(dmabuf))
+               return PTR_ERR(dmabuf);
 
        mutex_lock(&p->mutex);