mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Hung <alex.hung@amd.com>
To: Ma Ke <make24@iscas.ac.cn>,
	harry.wentland@amd.com, sunpeng.li@amd.com,
	Rodrigo.Siqueira@amd.com, alexander.deucher@amd.com,
	christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com,
	simona@ffwll.ch, wenjing.liu@amd.com, dillon.varone@amd.com,
	Samson.Tam@amd.com, yi-lchen@amd.com, chris.park@amd.com,
	aurabindo.pillai@amd.com, george.shen@amd.com,
	gabe.teeger@amd.com, Yihan.Zhu@amd.com, Tony.Cheng@amd.com
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] drm/amd/display: Fix null check for pipe_ctx->plane_state in resource_build_scaling_params
Date: Tue, 25 Feb 2025 15:53:38 -0700	[thread overview]
Message-ID: <14852987-a774-4952-a166-b84880566564@amd.com> (raw)
In-Reply-To: <20250224063218.2953217-1-make24@iscas.ac.cn>



On 2/23/25 23:32, Ma Ke wrote:
> Null pointer dereference issue could occur when pipe_ctx->plane_state
> is null. The fix adds a check to ensure 'pipe_ctx->plane_state' is not
> null before accessing. This prevents a null pointer dereference.
> 
> Found by code review.
> 
> Cc: stable@vger.kernel.org
> Fixes: 3be5262e353b ("drm/amd/display: Rename more dc_surface stuff to plane_state")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>   drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> index 520a34a42827..88e8ae63a07f 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> @@ -1452,6 +1452,9 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
>   	struct scaling_taps temp = {0};
>   	bool res = false;
>   
> +	if (!plane_state)
> +		return false;
> +

This if statement can be merged with the following one such as below, 
and it also allows ASSERT to kick in instead of failing silently.


         DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);

         /* Invalid input */
-       if (!plane_state->dst_rect.width ||
-                       !plane_state->dst_rect.height ||
-                       !plane_state->src_rect.width ||
-                       !plane_state->src_rect.height) {
+       if (!plane_state ||
+           !plane_state->dst_rect.width ||
+           !plane_state->dst_rect.height ||
+           !plane_state->src_rect.width ||
+           !plane_state->src_rect.height) {
                 ASSERT(0);


>   	DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
>   
>   	/* Invalid input */


      reply	other threads:[~2025-02-25 22:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24  6:32 Ma Ke
2025-02-25 22:53 ` Alex Hung [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=14852987-a774-4952-a166-b84880566564@amd.com \
    --to=alex.hung@amd.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Samson.Tam@amd.com \
    --cc=Tony.Cheng@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=Yihan.Zhu@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chris.park@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=dillon.varone@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gabe.teeger@amd.com \
    --cc=george.shen@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=make24@iscas.ac.cn \
    --cc=simona@ffwll.ch \
    --cc=stable@vger.kernel.org \
    --cc=sunpeng.li@amd.com \
    --cc=wenjing.liu@amd.com \
    --cc=yi-lchen@amd.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®