nop_user_request() returns a request with an extra reference that the
caller must put. If intel_context_create() or nop_user_request() fails
while spinning, the loop bails to err_spin_rq without dropping the
reference held by last. Release it on those error paths.

Fixes: 0013f5f5c05d ("drm/i915/guc: Selftest for stealing of guc ids")
Cc: [email protected]
Signed-off-by: Wentao Liang <[email protected]>
---
 drivers/gpu/drm/i915/gt/uc/selftest_guc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c 
b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
index 63a75272924f..603843047d3c 100644
--- a/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
+++ b/drivers/gpu/drm/i915/gt/uc/selftest_guc.c
@@ -197,6 +197,8 @@ static int intel_guc_steal_guc_ids(void *arg)
                        ret = PTR_ERR(ce[context_index]);
                        guc_err(guc, "Failed to create context: %pe\n", 
ce[context_index]);
                        ce[context_index--] = NULL;
+                       if (last)
+                               i915_request_put(last);
                        goto err_spin_rq;
                }
 
@@ -207,6 +209,8 @@ static int intel_guc_steal_guc_ids(void *arg)
                        if ((ret != -EAGAIN) || !last) {
                                guc_err(guc, "Failed to create %srequest %d: 
%pe\n",
                                        last ? "" : "first ", context_index, 
ERR_PTR(ret));
+                               if (last)
+                                       i915_request_put(last);
                                goto err_spin_rq;
                        }
                } else {
-- 
2.34.1

Reply via email to