[Intel-gfx] [PATCH] drm/i915: Clean-up idr table if context create fails.

Daniel Vetter daniel at ffwll.ch
Mon Mar 30 08:43:34 PDT 2015


On Mon, Mar 30, 2015 at 08:03:58PM +0530, deepak.s at linux.intel.com wrote:
> From: Deepak S <deepak.s at linux.intel.com>
> 
> Cleanup idr table if any error happens after __create_hw_context() in
> i915_gem_create_context()
> 
> Signed-off-by: Deepak S <deepak.s at linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_context.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index f3e84c4..69bebe5 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -287,6 +287,8 @@ err_unpin:
>  	if (is_global_default_ctx && ctx->legacy_hw_ctx.rcs_state)
>  		i915_gem_object_ggtt_unpin(ctx->legacy_hw_ctx.rcs_state);
>  err_destroy:
> +	if (ctx->file_priv)
> +		idr_remove(&ctx->file_priv->context_idr, ctx->user_handle);

The common approach is to add a new err_idr: label at the op of the unwind
code and make the call to idr_remove unconditional.

Thanks, Daniel

>  	i915_gem_context_unreference(ctx);
>  	return ERR_PTR(ret);
>  }
> -- 
> 1.9.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list