mirror of
https://github.com/torvalds/linux.git
synced 2026-09-13 14:44:42 +02:00
accel/ethosu: fix job completion fence cleanup
ethosu_ioctl_submit_job() allocates done_fence before validating buffer
handles. Errors after allocation call ethosu_job_err_cleanup(), which frees
the job but leaks the uninitialized fence.
A scheduler dependency error also lets ethosu_job_run() return before
dma_fence_init(). Normal cleanup then passes a zeroed refcount to
dma_fence_put().
Release done_fence in the common cleanup path and use
dma_fence_was_initialized() to distinguish initialized fences from raw
allocations.
Fixes: 5a5e9c0228 ("accel: Add Arm Ethos-U NPU driver")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260716065219.931088-1-zhaoguohan@kylinos.cn?part=1
Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.cn>
Link: https://patch.msgid.link/20260717061145.1478139-6-zhaoguohan@kylinos.cn
[robh: also fix goto]
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
This commit is contained in:
parent
4d4be20216
commit
2d2a3adc91
|
|
@ -152,6 +152,13 @@ static void ethosu_job_err_cleanup(struct ethosu_job *job)
|
|||
|
||||
drm_gem_object_put(job->cmd_bo);
|
||||
|
||||
if (job->done_fence) {
|
||||
if (dma_fence_was_initialized(job->done_fence))
|
||||
dma_fence_put(job->done_fence);
|
||||
else
|
||||
dma_fence_free(job->done_fence);
|
||||
}
|
||||
|
||||
kfree(job);
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +169,6 @@ static void ethosu_job_cleanup(struct kref *ref)
|
|||
|
||||
pm_runtime_put_autosuspend(job->dev->base.dev);
|
||||
|
||||
dma_fence_put(job->done_fence);
|
||||
dma_fence_put(job->inference_done_fence);
|
||||
|
||||
ethosu_job_err_cleanup(job);
|
||||
|
|
@ -393,7 +399,7 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
|
|||
ejob->done_fence = kzalloc_obj(*ejob->done_fence);
|
||||
if (!ejob->done_fence) {
|
||||
ret = -ENOMEM;
|
||||
goto out_cleanup_job;
|
||||
goto out_put_job;
|
||||
}
|
||||
|
||||
ret = drm_sched_job_init(&ejob->base,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user