mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] drm/amd/display: Fix null check for pipe_ctx->plane_state in resource_build_scaling_params
@ 2025-02-26  8:37 Ma Ke
  2025-02-26 18:47 ` Alex Hung
  0 siblings, 1 reply; 3+ messages in thread
From: Ma Ke @ 2025-02-26  8:37 UTC (permalink / raw)
  To: alex.hung, dillon.varone, Samson.Tam, chris.park,
	aurabindo.pillai, george.shen, gabe.teeger, Yihan.Zhu,
	Tony.Cheng
  Cc: amd-gfx, dri-devel, linux-kernel, Ma Ke, stable

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>
---
Changes in v2:
- modified the patch as suggestions.
---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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..a45037cb4cc0 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -1455,7 +1455,8 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
 	DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
 
 	/* Invalid input */
-	if (!plane_state->dst_rect.width ||
+	if (!plane_state ||
+			!plane_state->dst_rect.width ||
 			!plane_state->dst_rect.height ||
 			!plane_state->src_rect.width ||
 			!plane_state->src_rect.height) {
-- 
2.25.1


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

* Re: [PATCH v2] drm/amd/display: Fix null check for pipe_ctx->plane_state in resource_build_scaling_params
  2025-02-26  8:37 [PATCH v2] drm/amd/display: Fix null check for pipe_ctx->plane_state in resource_build_scaling_params Ma Ke
@ 2025-02-26 18:47 ` Alex Hung
  2025-02-26 19:16   ` Alex Deucher
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Hung @ 2025-02-26 18:47 UTC (permalink / raw)
  To: Ma Ke, dillon.varone, Samson.Tam, chris.park, aurabindo.pillai,
	george.shen, gabe.teeger, Yihan.Zhu, Tony.Cheng
  Cc: amd-gfx, dri-devel, linux-kernel, stable

Reviewed-by: Alex Hung <alex.hung@amd.com>

On 2/26/25 01:37, 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>
> ---
> Changes in v2:
> - modified the patch as suggestions.
> ---
>   drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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..a45037cb4cc0 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> @@ -1455,7 +1455,8 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
>   	DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
>   
>   	/* Invalid input */
> -	if (!plane_state->dst_rect.width ||
> +	if (!plane_state ||
> +			!plane_state->dst_rect.width ||
>   			!plane_state->dst_rect.height ||
>   			!plane_state->src_rect.width ||
>   			!plane_state->src_rect.height) {


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

* Re: [PATCH v2] drm/amd/display: Fix null check for pipe_ctx->plane_state in resource_build_scaling_params
  2025-02-26 18:47 ` Alex Hung
@ 2025-02-26 19:16   ` Alex Deucher
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2025-02-26 19:16 UTC (permalink / raw)
  To: Alex Hung
  Cc: Ma Ke, dillon.varone, Samson.Tam, chris.park, aurabindo.pillai,
	george.shen, gabe.teeger, Yihan.Zhu, Tony.Cheng, amd-gfx,
	dri-devel, linux-kernel, stable

Applied.  Thanks!

Alex

On Wed, Feb 26, 2025 at 2:04 PM Alex Hung <alex.hung@amd.com> wrote:
>
> Reviewed-by: Alex Hung <alex.hung@amd.com>
>
> On 2/26/25 01:37, 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>
> > ---
> > Changes in v2:
> > - modified the patch as suggestions.
> > ---
> >   drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > 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..a45037cb4cc0 100644
> > --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> > +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> > @@ -1455,7 +1455,8 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx)
> >       DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
> >
> >       /* Invalid input */
> > -     if (!plane_state->dst_rect.width ||
> > +     if (!plane_state ||
> > +                     !plane_state->dst_rect.width ||
> >                       !plane_state->dst_rect.height ||
> >                       !plane_state->src_rect.width ||
> >                       !plane_state->src_rect.height) {
>

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

end of thread, other threads:[~2025-02-26 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-26  8:37 [PATCH v2] drm/amd/display: Fix null check for pipe_ctx->plane_state in resource_build_scaling_params Ma Ke
2025-02-26 18:47 ` Alex Hung
2025-02-26 19:16   ` Alex Deucher

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®