All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/syncobj: Fix fence and syncobj leak on dma_fence_chain_alloc failure
@ 2026-11-06  9:57 tongzhiwei
  2026-11-06 10:10 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: tongzhiwei @ 2026-11-06  9:57 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, David Airlie
  Cc: tongzhiwei, dri-devel, linux-kernel

NOTE: this commit is worked by llm completely

In drm_syncobj_import_sync_file_fence(), when point is non-zero and
dma_fence_chain_alloc() returns NULL, the function returns -ENOMEM
without releasing the fence reference (obtained via sync_file_get_fence)
or the syncobj reference (obtained via drm_syncobj_find).  Both
references are permanently leaked.

Add dma_fence_put(fence) and drm_syncobj_put(syncobj) before returning
-ENOMEM on the allocation failure path.

Assisted-by: LLM
Signed-off-by: tongzhiwei <tongzhiwei@cmss.chinamobile.com>
---
 drivers/gpu/drm/drm_syncobj.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index f1d4da168545..1825055e9b54 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -743,8 +743,11 @@ static int drm_syncobj_import_sync_file_fence(struct drm_file *file_private,
 	if (point) {
 		struct dma_fence_chain *chain = dma_fence_chain_alloc();
 
-		if (!chain)
+		if (!chain) {
+			dma_fence_put(fence);
+			drm_syncobj_put(syncobj);
 			return -ENOMEM;
+		}
 
 		drm_syncobj_add_point(syncobj, chain, fence, point);
 	} else {
-- 
2.43.0




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

end of thread, other threads:[~2026-11-07 14:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06  9:57 [PATCH] drm/syncobj: Fix fence and syncobj leak on dma_fence_chain_alloc failure tongzhiwei
2026-11-06 10:10 ` sashiko-bot

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.