public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH] drm/modeset_lock: add NULL check for ctx before WARN_ON
@ 2026-04-29  2:59 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-05-05  1:50 ` Claude review: drm/modeset_lock: add NULL check for ctx before WARN_ON Claude Code Review Bot
  0 siblings, 2 replies; 9+ messages in thread
From: george.d.sworo @ 2026-04-29  2:59 UTC (permalink / raw)
  To: maarten.lankhorst; +Cc: dri-devel, George D Sworo

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


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

end of thread, other threads:[~2026-05-05  1:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [PATCH v2 1/2] drm/modeset_lock: add NULL check for ctx before WARN_ON george.d.sworo
2026-04-29 11:09     ` 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

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