[PATCH] drm/i915/gt: Fix rq use-after-free in perf_mi_noop()
From: Wentao Liang
Date: Wed Sep 16 2026 - 13:33:35 EST
The i915_request_put() after the wait may drop the final reference and
free the request, yet the following cycle counting still reads
rq->hwsp_seqno. Compute the cycles[] entry while the reference taken
before i915_request_add() is still held.
Fixes: 3c7a44bbbfa7 ("drm/i915/selftests: Perform some basic cycle counting of MI ops")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
index 5ffa5e30f419..7503763136b2 100644
--- a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
@@ -351,13 +351,14 @@ static int perf_mi_noop(void *arg)
if (i915_request_wait(rq, 0, HZ / 5) < 0)
err = -EIO;
+ if (err == 0)
+ cycles[i] =
+ (rq->hwsp_seqno[4] - rq->hwsp_seqno[3]) -
+ (rq->hwsp_seqno[3] - rq->hwsp_seqno[2]);
+
i915_request_put(rq);
if (err)
break;
-
- cycles[i] =
- (rq->hwsp_seqno[4] - rq->hwsp_seqno[3]) -
- (rq->hwsp_seqno[3] - rq->hwsp_seqno[2]);
}
i915_vma_put(nop);
i915_vma_put(base);
--
2.34.1