[PATCH] drm/syncobj: Fix fence and syncobj leak on dma_fence_chain_alloc failure
From: tongzhiwei
Date: Fri Nov 06 2026 - 05:16:06 EST
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@xxxxxxxxxxxxxxxxxxxx>
---
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