[Intel-gfx] [PATCH 1/2] drm/i915: Check new context against kernel_context after reporting an error
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Wed Jul 5 13:46:11 UTC 2017
On 05/07/2017 14:18, Chris Wilson wrote:
> Avoid any pointer dereference in inspecting a potential PTR_ERR by
> checking for the error pointer before checking for an invalid context.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_gem_context.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 2eb5d8203999..98d2ce98f467 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -571,14 +571,13 @@ int i915_gem_context_open(struct drm_i915_private *i915,
> mutex_lock(&i915->drm.struct_mutex);
> ctx = i915_gem_create_context(i915, file_priv);
> mutex_unlock(&i915->drm.struct_mutex);
> -
> - GEM_BUG_ON(i915_gem_context_is_kernel(ctx));
> -
> if (IS_ERR(ctx)) {
> idr_destroy(&file_priv->context_idr);
> return PTR_ERR(ctx);
> }
>
> + GEM_BUG_ON(i915_gem_context_is_kernel(ctx));
> +
> return 0;
> }
>
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Regards,
Tvrtko
More information about the Intel-gfx
mailing list