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

Chris Wilson chris at chris-wilson.co.uk
Thu Mar 1 10:26:50 UTC 2018


Quoting Matthew Auld (2018-03-01 10:18:55)
> 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>

Worth backporting? Not sure, as the leak will be forcibly freed when
the context is freed. We should spit a warning in that case, which as
you haven't quoted I presume this was found by inspection rather than
hit?

>  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;
> +               }
>  
>                 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:
err_unpin_ctx: or out_unpin_ctx: if Joonas is listening.

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the Intel-gfx mailing list