Skip to content

Commit 408c2f1

Browse files
ashutoshxrodrigovivi
authored andcommitted
drm/xe/exec: Fix minor bug related to xe_sync_entry_cleanup
Increment num_syncs after xe_sync_entry_parse() is successful to ensure the xe_sync_entry_cleanup() logic under "err_syncs" label works correctly. v2: Use the same pattern as that in xe_vm.c (Matt Brost) Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Signed-off-by: Ashutosh Dixit <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 43a6faa) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 478a527 commit 408c2f1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/gpu/drm/xe/xe_exec.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
118118
u64 addresses[XE_HW_ENGINE_MAX_INSTANCE];
119119
struct drm_gpuvm_exec vm_exec = {.extra.fn = xe_exec_fn};
120120
struct drm_exec *exec = &vm_exec.exec;
121-
u32 i, num_syncs = 0, num_ufence = 0;
121+
u32 i, num_syncs, num_ufence = 0;
122122
struct xe_sched_job *job;
123123
struct xe_vm *vm;
124124
bool write_locked, skip_retry = false;
@@ -156,15 +156,15 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
156156

157157
vm = q->vm;
158158

159-
for (i = 0; i < args->num_syncs; i++) {
160-
err = xe_sync_entry_parse(xe, xef, &syncs[num_syncs++],
161-
&syncs_user[i], SYNC_PARSE_FLAG_EXEC |
159+
for (num_syncs = 0; num_syncs < args->num_syncs; num_syncs++) {
160+
err = xe_sync_entry_parse(xe, xef, &syncs[num_syncs],
161+
&syncs_user[num_syncs], SYNC_PARSE_FLAG_EXEC |
162162
(xe_vm_in_lr_mode(vm) ?
163163
SYNC_PARSE_FLAG_LR_MODE : 0));
164164
if (err)
165165
goto err_syncs;
166166

167-
if (xe_sync_is_ufence(&syncs[i]))
167+
if (xe_sync_is_ufence(&syncs[num_syncs]))
168168
num_ufence++;
169169
}
170170

@@ -325,8 +325,8 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
325325
if (err == -EAGAIN && !skip_retry)
326326
goto retry;
327327
err_syncs:
328-
for (i = 0; i < num_syncs; i++)
329-
xe_sync_entry_cleanup(&syncs[i]);
328+
while (num_syncs--)
329+
xe_sync_entry_cleanup(&syncs[num_syncs]);
330330
kfree(syncs);
331331
err_exec_queue:
332332
xe_exec_queue_put(q);

0 commit comments

Comments
 (0)