From: Chris Wilson Date: Tue, 22 Nov 2016 14:41:18 +0000 (+0000) Subject: drm/i915: Don't deref context->file_priv ERR_PTR upon reset X-Git-Tag: v4.14-rc1~674^2~37^2~803 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d9e9da64c4a762493c5ac24b3b2bbc43c2754786;p=platform%2Fkernel%2Flinux-rpi.git drm/i915: Don't deref context->file_priv ERR_PTR upon reset When a user context is closed, it's file_priv backpointer is replaced by ERR_PTR(-EBADF); be careful not to chase this invalid pointer after a hang and a GPU reset. Signed-off-by: Chris Wilson Fixes: b083a0870c79 ("drm/i915: Add per client max context ban limit") Cc: Mika Kuoppala Reviewed-by: Mika Kuoppala Link: http://patchwork.freedesktop.org/patch/msgid/20161122144121.7379-1-chris@chris-wilson.co.uk --- diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index b38d4f8..b0dd0f0 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2647,16 +2647,12 @@ static void i915_gem_context_mark_guilty(struct i915_gem_context *ctx) ctx->name, ctx->ban_score, yesno(ctx->banned)); - if (!ctx->file_priv) + if (!ctx->banned || IS_ERR_OR_NULL(ctx->file_priv)) return; - if (ctx->banned) { - ctx->file_priv->context_bans++; - - DRM_DEBUG_DRIVER("client %s has has %d context banned\n", - ctx->name, - ctx->file_priv->context_bans); - } + ctx->file_priv->context_bans++; + DRM_DEBUG_DRIVER("client %s has had %d context banned\n", + ctx->name, ctx->file_priv->context_bans); } static void i915_gem_context_mark_innocent(struct i915_gem_context *ctx)