Skip to content

Commit 1bfd757

Browse files
ShuichengLinrodrigovivi
authored andcommitted
drm/xe/sync: Cleanup partially initialized sync on parse failure
xe_sync_entry_parse() can allocate references (syncobj, fence, chain fence, or user fence) before hitting a later failure path. Several of those paths returned directly, leaving partially initialized state and leaking refs. Route these error paths through a common free_sync label and call xe_sync_entry_cleanup(sync) before returning the error. Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20260219233516.2938172-5-shuicheng.lin@intel.com (cherry picked from commit f939bdd) Cc: stable@vger.kernel.org Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 43d37df commit 1bfd757

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

drivers/gpu/drm/xe/xe_sync.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
146146

147147
if (!signal) {
148148
sync->fence = drm_syncobj_fence_get(sync->syncobj);
149-
if (XE_IOCTL_DBG(xe, !sync->fence))
150-
return -EINVAL;
149+
if (XE_IOCTL_DBG(xe, !sync->fence)) {
150+
err = -EINVAL;
151+
goto free_sync;
152+
}
151153
}
152154
break;
153155

@@ -167,17 +169,21 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
167169

168170
if (signal) {
169171
sync->chain_fence = dma_fence_chain_alloc();
170-
if (!sync->chain_fence)
171-
return -ENOMEM;
172+
if (!sync->chain_fence) {
173+
err = -ENOMEM;
174+
goto free_sync;
175+
}
172176
} else {
173177
sync->fence = drm_syncobj_fence_get(sync->syncobj);
174-
if (XE_IOCTL_DBG(xe, !sync->fence))
175-
return -EINVAL;
178+
if (XE_IOCTL_DBG(xe, !sync->fence)) {
179+
err = -EINVAL;
180+
goto free_sync;
181+
}
176182

177183
err = dma_fence_chain_find_seqno(&sync->fence,
178184
sync_in.timeline_value);
179185
if (err)
180-
return err;
186+
goto free_sync;
181187
}
182188
break;
183189

@@ -216,6 +222,10 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef,
216222
sync->timeline_value = sync_in.timeline_value;
217223

218224
return 0;
225+
226+
free_sync:
227+
xe_sync_entry_cleanup(sync);
228+
return err;
219229
}
220230
ALLOW_ERROR_INJECTION(xe_sync_entry_parse, ERRNO);
221231

0 commit comments

Comments
 (0)