mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Add null check before access structs
@ 2024-06-26 13:06 Ma Ke
  2024-06-26 16:25 ` Markus Elfring
  2024-06-26 17:57 ` Aurabindo Pillai
  0 siblings, 2 replies; 4+ messages in thread
From: Ma Ke @ 2024-06-26 13:06 UTC (permalink / raw)
  To: harry.wentland, sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
	christian.koenig, Xinhui.Pan, airlied, daniel, jun.lei,
	wayne.lin, dillon.varone, nicholas.kazlauskas, Qingqing.Zhuo,
	stylon.wang, make24
  Cc: amd-gfx, dri-devel, linux-kernel

In enable_phantom_plane, we should better check null pointer before
accessing various structs.

Fixes: 09a4ec5da92c ("drm/amd/display: Refactor dc_state interface")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c
index 282d70e2b18a..3d29169dd6bb 100644
--- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c
+++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c
@@ -750,6 +750,8 @@ static void enable_phantom_plane(struct dml2_context *ctx,
 					ctx->config.svp_pstate.callbacks.dc,
 					state,
 					curr_pipe->plane_state);
+			if (!phantom_plane)
+				return;
 		}
 
 		memcpy(&phantom_plane->address, &curr_pipe->plane_state->address, sizeof(phantom_plane->address));
-- 
2.25.1


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

* Re: [PATCH] drm/amd/display: Add null check before access structs
  2024-06-26 13:06 [PATCH] drm/amd/display: Add null check before access structs Ma Ke
@ 2024-06-26 16:25 ` Markus Elfring
  2024-06-26 17:57 ` Aurabindo Pillai
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2024-06-26 16:25 UTC (permalink / raw)
  To: Ma Ke, amd-gfx, dri-devel, Alex Deucher, Christian König,
	Daniel Vetter, David Airlie, Dillon Varone, Harry Wentland,
	Jun Lei, Leo Li, Nicholas Kazlauskas, Qingqing Zhuo,
	Rodrigo Siqueira, Stylon Wang, Wayne Lin, Xinhui Pan
  Cc: LKML

> In enable_phantom_plane, we should better check null pointer before
> accessing various structs.

1. Can a wording approach (like the following) be a better change description?
   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc5#n45

   A null pointer is stored in the local variable “phantom_plane” after a call
   of the function “create_phantom_plane” (as a data structure menber) failed.
   This pointer was used in subsequent statements where an undesirable
   dereference will be performed then.
   Thus add a corresponding return value check.


2. How do you think about to use a summary phrase like
   “Prevent null pointer dereference in enable_phantom_plane()”?

Regards,
Markus

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

* Re: [PATCH] drm/amd/display: Add null check before access structs
  2024-06-26 13:06 [PATCH] drm/amd/display: Add null check before access structs Ma Ke
  2024-06-26 16:25 ` Markus Elfring
@ 2024-06-26 17:57 ` Aurabindo Pillai
  2024-06-26 19:00   ` Markus Elfring
  1 sibling, 1 reply; 4+ messages in thread
From: Aurabindo Pillai @ 2024-06-26 17:57 UTC (permalink / raw)
  To: Ma Ke, harry.wentland, sunpeng.li, Rodrigo.Siqueira,
	alexander.deucher, christian.koenig, Xinhui.Pan, airlied, daniel,
	jun.lei, wayne.lin, dillon.varone, nicholas.kazlauskas,
	Qingqing.Zhuo, stylon.wang
  Cc: amd-gfx, dri-devel, linux-kernel

Thanks for the fix, I'll apply this.

On 6/26/24 9:06 AM, Ma Ke wrote:
> In enable_phantom_plane, we should better check null pointer before
> accessing various structs.
> 
> Fixes: 09a4ec5da92c ("drm/amd/display: Refactor dc_state interface")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>   drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c
> index 282d70e2b18a..3d29169dd6bb 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_mall_phantom.c
> @@ -750,6 +750,8 @@ static void enable_phantom_plane(struct dml2_context *ctx,
>   					ctx->config.svp_pstate.callbacks.dc,
>   					state,
>   					curr_pipe->plane_state);
> +			if (!phantom_plane)
> +				return;
>   		}
>   
>   		memcpy(&phantom_plane->address, &curr_pipe->plane_state->address, sizeof(phantom_plane->address));

-- 
--

Thanks & Regards,
Aurabindo Pillai

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

* Re: [PATCH] drm/amd/display: Add null check before access structs
  2024-06-26 17:57 ` Aurabindo Pillai
@ 2024-06-26 19:00   ` Markus Elfring
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2024-06-26 19:00 UTC (permalink / raw)
  To: Aurabindo Pillai, Ma Ke, amd-gfx, dri-devel
  Cc: LKML, Alex Deucher, Christian König, Daniel Vetter,
	David Airlie, Dillon Varone, Harry Wentland, Jun Lei, Leo Li,
	Nicholas Kazlauskas, Qingqing Zhuo, Rodrigo Siqueira, Wayne Lin,
	Xinhui Pan

> > In enable_phantom_plane, we should better check null pointer before
> > accessing various structs.
>
> Thanks for the fix, I'll apply this.

Do you care for better commit messages and summary phrases?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc5#n45

Regards,
Markus

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

end of thread, other threads:[~2024-06-26 19:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-26 13:06 [PATCH] drm/amd/display: Add null check before access structs Ma Ke
2024-06-26 16:25 ` Markus Elfring
2024-06-26 17:57 ` Aurabindo Pillai
2024-06-26 19:00   ` Markus Elfring

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®