All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drm/amdkfd: Fix leak in dmabuf import
@ 2020-12-08 17:31 Felix Kuehling
  2020-12-08 18:35 ` Russell, Kent
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Kuehling @ 2020-12-08 17:31 UTC (permalink / raw)
  To: amd-gfx

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>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 222f1df1a6b6..8cc51cec988a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -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 @@ static int kfd_ioctl_import_dmabuf(struct file *filep,
 	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;
 }
 
-- 
2.29.2

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH 1/1] drm/amdkfd: Fix leak in dmabuf import
  2020-12-08 17:31 [PATCH 1/1] drm/amdkfd: Fix leak in dmabuf import Felix Kuehling
@ 2020-12-08 18:35 ` Russell, Kent
  0 siblings, 0 replies; 2+ messages in thread
From: Russell, Kent @ 2020-12-08 18:35 UTC (permalink / raw)
  To: Kuehling, Felix, amd-gfx

[AMD Public Use]

Seems logical to me.
Reviewed-by: Kent Russell <kent.russell@amd.com>

> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Felix Kuehling
> Sent: Tuesday, December 8, 2020 12:31 PM
> To: amd-gfx@lists.freedesktop.org
> Subject: [PATCH 1/1] drm/amdkfd: Fix leak in dmabuf import
> 
> 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>
> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 222f1df1a6b6..8cc51cec988a 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -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 @@ static int kfd_ioctl_import_dmabuf(struct file *filep,
>  	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;
>  }
> 
> --
> 2.29.2
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.or
> g%2Fmailman%2Flistinfo%2Famd-
> gfx&amp;data=04%7C01%7Ckent.russell%40amd.com%7Cce3f82630f6649b4303408d89b9f1
> b2c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637430454956092554%7CUnk
> nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV
> CI6Mn0%3D%7C1000&amp;sdata=WzPu3OlZKKBnTQKHqC7KczU5Z19%2BPhTUt2%2FdjKznM
> Ic%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-08 18:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 17:31 [PATCH 1/1] drm/amdkfd: Fix leak in dmabuf import Felix Kuehling
2020-12-08 18:35 ` Russell, Kent

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.