accel/rocket: fix ignored return value in rocket_ioctl_submit
PATCH 1/1 accel/rocket: fix ignored return value in rocket_ioctl_submit
rocket_ioctl_submit() calls rocket_ioctl_submit_job() in a loop but ignores its return value. If any job submission fails, the error is silently dropped and the function returns 0 (success) to userspace, leaving subsequent jobs potentially in an inconsistent state.
Fix this by propagating the error and breaking out of the loop on the first failure.
--- drivers/accel/rocket/rocket_job.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/accel/rocket/rocket_job.c +5 -2
@@ -626,8 +626,11 @@ int rocket_ioctl_submit(struct drm_device *dev, void *data, struct drm_file *fil } -for (i =0 ; i < args->job_count; i++) -rocket_ioctl_submit_job (dev, file, &jobs[i]); +for (i =0 ; i < args->job_count; i++) { + ret =rocket_ioctl_submit_job (dev, file, &jobs[i]); +if (ret) + goto exit; + } exit:kvfree (jobs);
Signature · 1 line
2.50.0
Hi,
Quoted 7 lines · Kartik Nair
rocket_ioctl_submit()callsrocket_ioctl_submit_job()in a loop but ignores its return value. If any job submission fails, the error is silently dropped and the function returns 0 (success) to userspace, leaving subsequent jobs potentially in an inconsistent state.Fix this by propagating the error and breaking out of the loop on the first failure.
There's definitely a bug in there, but this approach is just replacing one incorrect behaviour with another.
After your change if there is an -EINTR generated from within the job submission, this will cause drmIoctl to retry the exact same job sequence, likely causing parts of the sequence to be repeated, possibly with negative consequences.
And on other error paths that would be bubbled up by your change, userspace won't be able to know which parts of the sequence ran vs failed.
I think we need a deeper change here. Is it possible to fully prepare and arm the whole job list first, without executing yet, returning an error code if anything goes wrong in the process?
Then the execution of the job list could happen as a second stage, hopefully without any possibility of failure.
Daniel
Hi,
Quoted 20 lines · Daniel Drake
Hi,
Quoted 7 lines · Kartik Nair
rocket_ioctl_submit()callsrocket_ioctl_submit_job()in a loop but ignores its return value. If any job submission fails, the error is silently dropped and the function returns 0 (success) to userspace, leaving subsequent jobs potentially in an inconsistent state.Fix this by propagating the error and breaking out of the loop on the first failure.
There's definitely a bug in there, but this approach is just replacing one incorrect behaviour with another.
After your change if there is an
-EINTRgenerated from within the job submission, this will cause drmIoctl to retry the exact same job sequence, likely causing parts of the sequence to be repeated, possibly with negative consequences.
Quoted 6 lines
And on other error paths that would be bubbled up by your change, userspace won't be able to know which parts of the sequence ran vs failed.
I think we need a deeper change here. Is it possible to fully prepare and arm the whole job list first, without executing yet, returning an error code if anything goes wrong in the process?
I agree with Daniel.
How about splitting rocket_ioctl_submit_job() into a prepare step (everything that can fail) and an arm + push step,
and first preparing all jobs to check for errors?
Signature · 2 lines
Thanks, Gyeyoung