All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Subject: [PATCH] drm/i915/selftests: Avoid ERR_PTR dereference
Date: Wed, 20 Jun 2018 12:24:41 +0100	[thread overview]
Message-ID: <20180620112441.13085-1-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20180620110907.pnr5zrqmsko4cyvy@kili.mountain>

Along the early error path for igt_switch_to_kernel_context we may try
to dereference an invalid error pointer. Instead, return early rather
than dump the GEM trace since we haven't yet emitted anything of
interest.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 09a4c02e58c1 ("drm/i915: Look for an active kernel context before switching")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/selftests/i915_gem_context.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
index 836f1af8b833..90c3c36173ba 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
@@ -519,8 +519,8 @@ static int igt_switch_to_kernel_context(void *arg)
 	mutex_lock(&i915->drm.struct_mutex);
 	ctx = kernel_context(i915);
 	if (IS_ERR(ctx)) {
-		err = PTR_ERR(ctx);
-		goto out_unlock;
+		mutex_unlock(&i915->drm.struct_mutex);
+		return PTR_ERR(ctx);
 	}
 
 	/* First check idling each individual engine */
-- 
2.18.0.rc2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-06-20 11:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-20 11:09 [PATCH] drm/i915/selftests: Don't dereference an error pointer Dan Carpenter
2018-06-20 11:09 ` Dan Carpenter
2018-06-20 11:20 ` [PATCH] ctx-sync Chris Wilson
2018-06-20 11:25   ` Chris Wilson
2018-06-20 11:24 ` Chris Wilson [this message]
2018-06-20 12:04   ` [PATCH] drm/i915/selftests: Avoid ERR_PTR dereference Joonas Lahtinen
2018-06-20 11:36 ` ✗ Fi.CI.BAT: failure for drm/i915/selftests: Don't dereference an error pointer Patchwork
2018-06-20 11:56 ` ✓ Fi.CI.BAT: success for drm/i915/selftests: Don't dereference an error pointer (rev3) Patchwork
2018-06-20 12:45 ` ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180620112441.13085-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=mika.kuoppala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.