[Intel-gfx] [PATCH] drm/i915: don't leak the pin_map on error

Mika Kuoppala mika.kuoppala at linux.intel.com
Thu Mar 1 10:25:32 UTC 2018


Matthew Auld <matthew.auld at intel.com> writes:

> Add some onion to populate_lr_context.
>
> Fixes: d2b4b97933f5 ("drm/i915: Record the default hw state after reset upon load")
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/intel_lrc.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index 14288743909f..9dd6440eb0e1 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -2318,8 +2318,10 @@ populate_lr_context(struct i915_gem_context *ctx,
>  
>  		defaults = i915_gem_object_pin_map(engine->default_state,
>  						   I915_MAP_WB);
> -		if (IS_ERR(defaults))
> -			return PTR_ERR(defaults);
> +		if (IS_ERR(defaults)) {
> +			ret = PTR_ERR(defaults);
> +			goto error;

I would have used goto unpin_out or error_unpin. This
way you can read both parts separately and don't have to
go back and forth pairing the parts of onion. Just
a stylistic note and as this is the only goto in this
func so we can improve if it ever grows.

Reviewed-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>

> +		}
>  
>  		memcpy(vaddr + start, defaults + start, engine->context_size);
>  		i915_gem_object_unpin_map(engine->default_state);
> @@ -2337,9 +2339,9 @@ populate_lr_context(struct i915_gem_context *ctx,
>  			_MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT |
>  					   CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT);
>  
> +error:
>  	i915_gem_object_unpin_map(ctx_obj);
> -
> -	return 0;
> +	return ret;
>  }
>  
>  static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
> -- 
> 2.14.3
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx


More information about the Intel-gfx mailing list