public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: george.d.sworo@intel.com
To: maarten.lankhorst@linux.intel.com
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	George D Sworo <george.d.sworo@intel.com>
Subject: [PATCH v2 1/2] drm/modeset_lock: add NULL check for ctx before WARN_ON
Date: Tue, 28 Apr 2026 23:04:30 -0700	[thread overview]
Message-ID: <20260429060431.1462589-2-george.d.sworo@intel.com> (raw)
In-Reply-To: <20260429060431.1462589-1-george.d.sworo@intel.com>

From: George D Sworo <george.d.sworo@intel.com>

modeset_lock() and drm_modeset_drop_locks() do not validate
the ctx pointer before dereferencing it in WARN_ON(ctx->contended),
which can lead to a NULL pointer dereference if ctx is NULL.

Add a NULL check to prevent this.

Signed-off-by: George D Sworo <george.d.sworo@intel.com>
---
 drivers/gpu/drm/drm_modeset_lock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c
index beb91a13a312..2052bb9bb9e5 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -295,7 +295,7 @@ static inline int modeset_lock(struct drm_modeset_lock *lock,
 {
 	int ret;
 
-	if (WARN_ON(ctx->contended))
+	if (ctx && WARN_ON(ctx->contended))
 		__drm_stack_depot_print(ctx->stack_depot);
 
 	if (ctx->trylock_only) {
-- 
2.34.1


  reply	other threads:[~2026-04-29  6:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29  2:59 [PATCH] drm/modeset_lock: add NULL check for ctx before WARN_ON george.d.sworo
2026-04-29  6:04 ` [PATCH v2 0/2] drm/i915/modeset: fix NULL/ctx handling in lock paths george.d.sworo
2026-04-29  6:04   ` george.d.sworo [this message]
2026-04-29 11:09     ` [PATCH v2 1/2] drm/modeset_lock: add NULL check for ctx before WARN_ON Ville Syrjälä
2026-04-30  4:12       ` Sworo, George D
2026-04-29  6:04   ` [PATCH v2 2/2] drm/modeset: harden modeset_lock() against NULL ctx george.d.sworo
2026-05-05  1:50     ` Claude review: " Claude Code Review Bot
2026-05-05  1:50   ` Claude review: drm/i915/modeset: fix NULL/ctx handling in lock paths Claude Code Review Bot
2026-05-05  1:50 ` Claude review: drm/modeset_lock: add NULL check for ctx before WARN_ON Claude Code Review Bot

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=20260429060431.1462589-2-george.d.sworo@intel.com \
    --to=george.d.sworo@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.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