Skip to contentSkip to conversation

drm/amd/display: Add null check before access structs in dcn32_enable_phantom_plane

PATCH RESEND In review Ma Ke 2 participants 2 messages Sep 9, 2024

Subsystems (4)
lore
Share & tools
lore

Ma Ke

author
#0 lore raw

PATCH RESEND 1/1 drm/amd/display: Add null check before access structs in dcn32_enable_phantom_plane

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

Fixes 235c67634230 ("drm/amd/display: add DCN32/321 specific files for Display Core")
---
 drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +2 -0
index 969658313fd6..1d1b40d22f42 100644
@@ -1650,6 +1650,8 @@ static void dcn32_enable_phantom_plane(struct dc *dc,
 			phantom_plane = prev_phantom_plane;
 		else
 			phantom_plane = dc_state_create_phantom_plane(dc, context, curr_pipe->plane_state);
+		if (!phantom_plane)
+			return;
 
 		memcpy(&phantom_plane->address, &curr_pipe->plane_state->address, sizeof(phantom_plane->address));
 		memcpy(&phantom_plane->scaling_quality, &curr_pipe->plane_state->scaling_quality,
Signature · 1 line
2.25.1
#1 lore raw
Quoted 7 lines · Ma Ke

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

Fixes 235c67634230 ("drm/amd/display: add DCN32/321 specific files for Display Core")

Thanks for the patch. This is already fixed in:
https://gitlab.freedesktop.org/agd5f/linux/-/commit/fdd5ecbbff751c3b9061d8ebb08e5c96119915b4

Alex

Quoted 20 lines
---
 drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +2 -1
index 969658313fd6..1d1b40d22f42 100644
@@ -1650,6 +1650,8 @@ static void dcn32_enable_phantom_plane(struct dc *dc,
                        phantom_plane = prev_phantom_plane;
                else
                        phantom_plane = dc_state_create_phantom_plane(dc, context, curr_pipe->plane_state);
+               if (!phantom_plane)
+                       return;
 
                memcpy(&phantom_plane->address, &curr_pipe->plane_state->address, sizeof(phantom_plane->address));
                memcpy(&phantom_plane->scaling_quality, &curr_pipe->plane_state->scaling_quality,
--

2.25.1