mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: "Guangshuo Li" <lgs201920130244@gmail.com>,
	"Harry Wentland" <harry.wentland@amd.com>,
	"Leo Li" <sunpeng.li@amd.com>,
	"Rodrigo Siqueira" <siqueira@igalia.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Alex Hung" <alex.hung@amd.com>,
	"Mario Limonciello (AMD)" <superm1@kernel.org>,
	"Timur Kristóf" <timur.kristof@gmail.com>,
	"Ivan Lipski" <ivan.lipski@amd.com>,
	"Aurabindo Pillai" <aurabindo.pillai@amd.com>,
	"Ray Wu" <ray.wu@amd.com>, "Chenyu Chen" <chen-yu.chen@amd.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amd/display: move connector state dereference after NULL check
Date: Wed, 8 Jul 2026 12:11:24 -0500	[thread overview]
Message-ID: <2171fd97-275b-4e2e-836e-00c811984719@amd.com> (raw)
In-Reply-To: <20260708072751.724400-1-lgs201920130244@gmail.com>



On 7/8/26 02:27, Guangshuo Li wrote:
> amdgpu_dm_connector_atomic_check() checks whether the old or new
> connector state returned by the atomic helpers is NULL before using
> those pointers.
> 
> However, new_con_state is already dereferenced while initializing crtc,
> before the NULL check is reached. If
> drm_atomic_get_new_connector_state() returns NULL, the function can
> dereference the NULL pointer before the WARN_ON() check can handle it.
> 
> Declare crtc first and initialize it only after the NULL check has
> succeeded.
> 
> Fixes: 1e5e8d672fec ("drm/amd/display: Avoid a NULL pointer dereference")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---

Good finding.  I'll get this applied.

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>

>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index d3a8d681227a..7b040fd7e3fb 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -8640,13 +8640,14 @@ amdgpu_dm_connector_atomic_check(struct drm_connector *conn,
>   		drm_atomic_get_new_connector_state(state, conn);
>   	struct drm_connector_state *old_con_state =
>   		drm_atomic_get_old_connector_state(state, conn);
> -	struct drm_crtc *crtc = new_con_state->crtc;
> +	struct drm_crtc *crtc;
>   	struct drm_crtc_state *new_crtc_state;
>   	struct amdgpu_dm_connector *aconn = to_amdgpu_dm_connector(conn);
>   	int ret;
>   
>   	if (WARN_ON(unlikely(!old_con_state || !new_con_state)))
>   		return -EINVAL;
> +	crtc = new_con_state->crtc;
>   
>   	trace_amdgpu_dm_connector_atomic_check(new_con_state);
>   


      reply	other threads:[~2026-07-08 17:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08  7:27 Guangshuo Li
2026-07-08 17:11 ` Mario Limonciello [this message]

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=2171fd97-275b-4e2e-836e-00c811984719@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=airlied@gmail.com \
    --cc=alex.hung@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chen-yu.chen@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=ivan.lipski@amd.com \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=ray.wu@amd.com \
    --cc=simona@ffwll.ch \
    --cc=siqueira@igalia.com \
    --cc=sunpeng.li@amd.com \
    --cc=superm1@kernel.org \
    --cc=timur.kristof@gmail.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

all inboxes | Powered by JetHome®