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 --- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index 98bb5c9239de..1ac916b24891 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c @@ -598,7 +598,12 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, sync_file = sync_file_create(submit->out_fence); if (!sync_file) { ret = -ENOMEM; - goto err_submit_job; + /* + * When this late error is hit, the submit has already + * been handed over to the scheduler. At this point + * the sched_job must not be cleaned up. + */ + goto err_submit_put; } fd_install(out_fence_fd, sync_file->file); } @@ -607,7 +612,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, args->fence = submit->out_fence_id;
err_submit_job: - drm_sched_job_cleanup(&submit->sched_job); + if (ret) + drm_sched_job_cleanup(&submit->sched_job); err_submit_put: etnaviv_submit_put(submit);
On Wed, May 04, 2022 at 11:02:29AM +0200, Lucas Stach wrote:
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
Pushed to drm-misc-next, thanks for your patch to fix my bug :-) -Daniel
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c index 98bb5c9239de..1ac916b24891 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c @@ -598,7 +598,12 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, sync_file = sync_file_create(submit->out_fence); if (!sync_file) { ret = -ENOMEM;
goto err_submit_job;
/*
* When this late error is hit, the submit has already
* been handed over to the scheduler. At this point
* the sched_job must not be cleaned up.
*/
} fd_install(out_fence_fd, sync_file->file); }goto err_submit_put;
@@ -607,7 +612,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, args->fence = submit->out_fence_id;
err_submit_job:
- drm_sched_job_cleanup(&submit->sched_job);
- if (ret)
drm_sched_job_cleanup(&submit->sched_job);
err_submit_put: etnaviv_submit_put(submit);
-- 2.30.2
Am 2022-05-04 11:02, schrieb Lucas Stach:
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
FWIW (because it's already picked up)
Tested-by: Michael Walle michael@walle.cc
Thanks! -michael
On Wed, May 04, 2022 at 10:58:57PM +0200, Michael Walle wrote:
Am 2022-05-04 11:02, schrieb Lucas Stach:
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
FWIW (because it's already picked up)
Tested-by: Michael Walle michael@walle.cc
Thanks for confirming anyway, and apologies for breaking stuff - the bug has been pretty screaming when I looked at the changes in detail and I think I created it in one of the rebases and changes for drm_sched_job error handling, I should have been a bit more careful.
Cheers, Daniel
dri-devel@lists.freedesktop.org