drm/amdkfd: Fix leak in dmabuf import
authorFelix Kuehling <Felix.Kuehling@amd.com>
Tue, 8 Dec 2020 17:23:15 +0000 (12:23 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 9 Dec 2020 15:06:39 +0000 (10:06 -0500)
Release dmabuf reference before returning from kfd_ioctl_import_dmabuf.
amdgpu_amdkfd_gpuvm_import_dmabuf takes a reference to the underlying
GEM BO and doesn't keep the reference to the dmabuf wrapper.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Kent Russell <kent.russell@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c

index 222f1df..8cc51ce 100644 (file)
@@ -1736,6 +1736,7 @@ static int kfd_ioctl_import_dmabuf(struct file *filep,
        }
 
        mutex_unlock(&p->mutex);
+       dma_buf_put(dmabuf);
 
        args->handle = MAKE_HANDLE(args->gpu_id, idr_handle);
 
@@ -1745,6 +1746,7 @@ err_free:
        amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->kgd, (struct kgd_mem *)mem, NULL);
 err_unlock:
        mutex_unlock(&p->mutex);
+       dma_buf_put(dmabuf);
        return r;
 }