public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: george.d.sworo@intel.com
Cc: maarten.lankhorst@linux.intel.com,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] drm/modeset_lock: add NULL check for ctx before WARN_ON
Date: Wed, 29 Apr 2026 14:09:10 +0300	[thread overview]
Message-ID: <afHm1k0K0mDRPmJM@intel.com> (raw)
In-Reply-To: <20260429060431.1462589-2-george.d.sworo@intel.com>

On Tue, Apr 28, 2026 at 11:04:30PM -0700, george.d.sworo@intel.com wrote:
> 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.

Why are you trying to pass garbage into the function?

> 
> 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

-- 
Ville Syrjälä
Intel

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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260429025952.1202080-1-george.d.sworo@intel.com>
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ä [this message]
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

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=afHm1k0K0mDRPmJM@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=george.d.sworo@intel.com \
    --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