All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm 1/2] amdgpu: free flink bo in bo import
@ 2018-08-14  3:00 Junwei Zhang
       [not found] ` <1534215609-18668-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Junwei Zhang @ 2018-08-14  3:00 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Junwei Zhang, christian.koenig-5C7GfCeVMHo

Fix potential memory leak when handle flink bo in bo import.
Free the flink bo after bo import and in error handling.

Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com>
---
 amdgpu/amdgpu_bo.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index b790e9b..d9556ec 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -255,6 +255,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
 		     struct amdgpu_bo_import_result *output)
 {
 	struct drm_gem_open open_arg = {};
+	struct drm_gem_close close_arg = {};
 	struct amdgpu_bo *bo = NULL;
 	int r;
 	int dma_fd;
@@ -342,15 +343,19 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
 
 		bo->handle = open_arg.handle;
 		if (dev->flink_fd != dev->fd) {
+			close_arg.handle = open_arg.handle;
 			r = drmPrimeHandleToFD(dev->flink_fd, bo->handle, DRM_CLOEXEC, &dma_fd);
 			if (r) {
 				free(bo);
+				drmIoctl(dev->flink_fd, DRM_IOCTL_GEM_CLOSE,
+					 &close_arg);
 				pthread_mutex_unlock(&dev->bo_table_mutex);
 				return r;
 			}
 			r = drmPrimeFDToHandle(dev->fd, dma_fd, &bo->handle );
 
 			close(dma_fd);
+			drmIoctl(dev->flink_fd, DRM_IOCTL_GEM_CLOSE, &close_arg);
 
 			if (r) {
 				free(bo);
-- 
1.9.1

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

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

end of thread, other threads:[~2018-08-14  8:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-14  3:00 [PATCH libdrm 1/2] amdgpu: free flink bo in bo import Junwei Zhang
     [not found] ` <1534215609-18668-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
2018-08-14  3:00   ` [PATCH libdrm 2/2] amdgpu: add a function to create amdgpu bo internally (v4) Junwei Zhang
2018-08-14  8:26   ` [PATCH libdrm 1/2] amdgpu: free flink bo in bo import Christian König
     [not found]     ` <a1107170-5b53-8fbd-226c-f01323714c07-5C7GfCeVMHo@public.gmane.org>
2018-08-14  8:30       ` Zhang, Jerry (Junwei)

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.