Re: [PATCH] accel/rocket: Fix up sched array handling on open and close
From: Heiko Stübner
Date: Wed Nov 18 2026 - 05:52:10 EST
Am Mittwoch, 18. November 2026, 11:18:58 Mitteleuropäische Normalzeit schrieb Tomeu Vizoso:
> Don't WARN when drm_sched_entity_init() fails in rocket_job_open().
> It can return -ENOMEM, which is an allocation failure and not a
> driver bug, so it doesn't deserve a stack trace.
>
> Also free the scheduler array in rocket_job_close() only after the entity
> has been destroyed, so that entity->sched_list never points to freed
> memory.
>
> Fixes: d341ef030f3c ("accel/rocket: Check allocations before use")
> Fixes: 9bca2b5f1a4f ("accel/rocket: Keep scheduler allocation in rocket_file_priv")
> Suggested-by: Sidong Yang <sidong.yang@xxxxxxxxxx>
> Signed-off-by: Tomeu Vizoso <tomeu@xxxxxxxxxxxxxxx>
> Link: https://lore.kernel.org/all/20260826113538.42111-1-sidong.yang@xxxxxxxxxx/
> Link: https://lore.kernel.org/all/20260826113538.42111-2-sidong.yang@xxxxxxxxxx/
> ---
>
> This addresses a mistake I made when I missed the v6 of the
> "accel/rocket: Fix allocation handling and scheduler array leak" series
> and pushed v5 to drm-misc-fixes.
>
> With these changes, both drm-misc-fixes and drm-misc-next contain the
> same code in these functions and there should be no conflict when the
> two are merged.
>
> This is to apply to drm-misc-fixes only.
>
> ---
> drivers/accel/rocket/rocket_job.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
> index 7b798a90bc49..454d465a39e3 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
> @@ -572,7 +572,7 @@ int rocket_job_open(struct rocket_file_priv *rocket_priv)
> DRM_SCHED_PRIORITY_NORMAL,
> scheds,
> rdev->num_cores, NULL);
> - if (WARN_ON(ret))
> + if (ret)
> kfree(scheds);
> else
> rocket_priv->scheds = scheds;
> @@ -584,8 +584,8 @@ void rocket_job_close(struct rocket_file_priv *rocket_priv)
> {
> struct drm_sched_entity *entity = &rocket_priv->sched_entity;
>
> - kfree(rocket_priv->scheds);
> drm_sched_entity_destroy(entity);
> + kfree(rocket_priv->scheds);
> }
Reviewed-by: Heiko Stuebner <heiko@xxxxxxxxx>