Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/etnaviv: avoid cleaning up sched_job when submit succeeded

While the labels may mislead the casual reader, the tail of the function
etnaviv_ioctl_gem_submit is always executed, as a lot of the structures
set up in this function need to be cleaned up regardless of whether the
submit succeeded or failed.

An exception is the newly added drm_sched_job_cleanup, which must only
be called when the submit failed before handing the job to the
scheduler.

Fixes: b827c84f5e84 ("drm/etnaviv: Use scheduler dependency handling")
Reported-by: Michael Walle <michael@walle.cc>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220504090229.2506560-1-l.stach@pengutronix.de

authored by

Lucas Stach and committed by
Daniel Vetter
e123b4ed 420f95b0

+8 -2
+8 -2
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
··· 598 598 sync_file = sync_file_create(submit->out_fence); 599 599 if (!sync_file) { 600 600 ret = -ENOMEM; 601 - goto err_submit_job; 601 + /* 602 + * When this late error is hit, the submit has already 603 + * been handed over to the scheduler. At this point 604 + * the sched_job must not be cleaned up. 605 + */ 606 + goto err_submit_put; 602 607 } 603 608 fd_install(out_fence_fd, sync_file->file); 604 609 } ··· 612 607 args->fence = submit->out_fence_id; 613 608 614 609 err_submit_job: 615 - drm_sched_job_cleanup(&submit->sched_job); 610 + if (ret) 611 + drm_sched_job_cleanup(&submit->sched_job); 616 612 err_submit_put: 617 613 etnaviv_submit_put(submit); 618 614