public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/gt: Use IS_ERR() check for kernel_context() in selftests
@ 2026-05-14 19:32 Ingyu Jang
  2026-05-16  0:29 ` Claude review: " Claude Code Review Bot
  2026-05-16  0:29 ` Claude Code Review Bot
  0 siblings, 2 replies; 3+ messages in thread
From: Ingyu Jang @ 2026-05-14 19:32 UTC (permalink / raw)
  To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Simona Vetter
  Cc: intel-gfx, dri-devel, linux-kernel

kernel_context() returns an error pointer on failure, never NULL, so
the NULL checks on its return value are unreachable. On a real
allocation failure the subsequent dereference of the returned ERR_PTR
(e.g. ctx_hi->sched.priority = ...) would oops the test kernel.

Use IS_ERR() and propagate the actual error via PTR_ERR() in
live_preempt(), live_late_preempt(), live_preempt_timeout() and
preempt_client_init().

Signed-off-by: Ingyu Jang <ingyujang25@korea.ac.kr>
---
 drivers/gpu/drm/i915/gt/selftest_execlists.c | 28 ++++++++++++--------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/selftest_execlists.c b/drivers/gpu/drm/i915/gt/selftest_execlists.c
index 21e5ed9f72a30..36f51805f74e3 100644
--- a/drivers/gpu/drm/i915/gt/selftest_execlists.c
+++ b/drivers/gpu/drm/i915/gt/selftest_execlists.c
@@ -1742,13 +1742,15 @@ static int live_preempt(void *arg)
 	int err = -ENOMEM;
 
 	ctx_hi = kernel_context(gt->i915, NULL);
-	if (!ctx_hi)
-		return -ENOMEM;
+	if (IS_ERR(ctx_hi))
+		return PTR_ERR(ctx_hi);
 	ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY;
 
 	ctx_lo = kernel_context(gt->i915, NULL);
-	if (!ctx_lo)
+	if (IS_ERR(ctx_lo)) {
+		err = PTR_ERR(ctx_lo);
 		goto err_ctx_hi;
+	}
 	ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
 
 	if (igt_spinner_init(&spin_hi, gt))
@@ -1834,12 +1836,14 @@ static int live_late_preempt(void *arg)
 	int err = -ENOMEM;
 
 	ctx_hi = kernel_context(gt->i915, NULL);
-	if (!ctx_hi)
-		return -ENOMEM;
+	if (IS_ERR(ctx_hi))
+		return PTR_ERR(ctx_hi);
 
 	ctx_lo = kernel_context(gt->i915, NULL);
-	if (!ctx_lo)
+	if (IS_ERR(ctx_lo)) {
+		err = PTR_ERR(ctx_lo);
 		goto err_ctx_hi;
+	}
 
 	if (igt_spinner_init(&spin_hi, gt))
 		goto err_ctx_lo;
@@ -1934,8 +1938,8 @@ struct preempt_client {
 static int preempt_client_init(struct intel_gt *gt, struct preempt_client *c)
 {
 	c->ctx = kernel_context(gt->i915, NULL);
-	if (!c->ctx)
-		return -ENOMEM;
+	if (IS_ERR(c->ctx))
+		return PTR_ERR(c->ctx);
 
 	if (igt_spinner_init(&c->spin, gt))
 		goto err_ctx;
@@ -3384,13 +3388,15 @@ static int live_preempt_timeout(void *arg)
 		return 0;
 
 	ctx_hi = kernel_context(gt->i915, NULL);
-	if (!ctx_hi)
-		return -ENOMEM;
+	if (IS_ERR(ctx_hi))
+		return PTR_ERR(ctx_hi);
 	ctx_hi->sched.priority = I915_CONTEXT_MAX_USER_PRIORITY;
 
 	ctx_lo = kernel_context(gt->i915, NULL);
-	if (!ctx_lo)
+	if (IS_ERR(ctx_lo)) {
+		err = PTR_ERR(ctx_lo);
 		goto err_ctx_hi;
+	}
 	ctx_lo->sched.priority = I915_CONTEXT_MIN_USER_PRIORITY;
 
 	if (igt_spinner_init(&spin_lo, gt))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-16  0:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14 19:32 [PATCH] drm/i915/gt: Use IS_ERR() check for kernel_context() in selftests Ingyu Jang
2026-05-16  0:29 ` Claude review: " Claude Code Review Bot
2026-05-16  0:29 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox