Start checking drm_sched_entity_init() return value in preparation of making that API a bit stricter.
No functional change intended as the failure path should never trigger in this driver. Signed-off-by: Tvrtko Ursulin <[email protected]> Cc: Lucas Stach <[email protected]> Cc: Russell King <[email protected]> Cc: Christian Gmeiner <[email protected]> Cc: [email protected] --- Compile tested only. --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 7bd7aef723c3..53003c31d7f9 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -83,21 +83,29 @@ static int etnaviv_open(struct drm_device *dev, struct drm_file *file) } for (i = 0; i < ETNA_MAX_PIPES; i++) { - struct etnaviv_gpu *gpu = priv->gpu[i]; struct drm_gpu_scheduler *sched; - if (gpu) { - sched = &gpu->sched; - drm_sched_entity_init(&ctx->sched_entity[i], - DRM_SCHED_PRIORITY_NORMAL, &sched, - 1, NULL); - } + if (!priv->gpu[i]) + continue; + + sched = &priv->gpu[i]->sched; + ret = drm_sched_entity_init(&ctx->sched_entity[i], + DRM_SCHED_PRIORITY_NORMAL, + &sched, 1, NULL); + if (ret) + goto out_entity; } file->driver_priv = ctx; return 0; +out_entity: + while (i--) { + if (priv->gpu[i]) + drm_sched_entity_destroy(&ctx->sched_entity[i]); + } + etnaviv_iommu_context_put(ctx->mmu); out_id: xa_erase(&priv->active_contexts, ctx->id); out_free: -- 2.56.0
