dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Matthew Brost <matthew.brost@intel.com>, dri-devel@lists.freedesktop.org
Subject: [PATCH] drm/i915/selftests: fix error handling in guc_steal_ids
Date: Tue, 25 Jan 2022 12:02:45 +0000	[thread overview]
Message-ID: <20220125120245.2925308-1-matthew.auld@intel.com> (raw)

Ensure we drop the reference to the last rq, otherwise we are leaking
the context etc. Also don't zero the previous valid context.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/i915/gt/uc/selftest_guc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
index d3327b802b76..b170f6b6e729 100644
--- a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
+++ b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
@@ -190,7 +190,6 @@ static int intel_guc_steal_guc_ids(void *arg)
 		ce[++context_index] = intel_context_create(engine);
 		if (IS_ERR(ce[context_index])) {
 			ret = PTR_ERR(ce[context_index--]);
-			ce[context_index] = NULL;
 			pr_err("Failed to create context: %d\n", ret);
 			goto err_spin_rq;
 		}
@@ -226,6 +225,7 @@ static int intel_guc_steal_guc_ids(void *arg)
 	/* Wait for last request */
 	ret = i915_request_wait(last, 0, HZ * 30);
 	i915_request_put(last);
+	last = NULL;
 	if (ret < 0) {
 		pr_err("Last request failed to complete: %d\n", ret);
 		goto err_spin_rq;
@@ -271,6 +271,8 @@ static int intel_guc_steal_guc_ids(void *arg)
 		igt_spinner_fini(&spin);
 		intel_gt_wait_for_idle(gt, HZ * 30);
 	}
+	if (last)
+		i915_request_put(last);
 err_contexts:
 	for (; context_index >= 0 && ce[context_index]; --context_index)
 		intel_context_put(ce[context_index]);
-- 
2.34.1


                 reply	other threads:[~2022-01-25 12:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220125120245.2925308-1-matthew.auld@intel.com \
    --to=matthew.auld@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.brost@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox