Skip to contentSkip to conversation

drm/amd/display: Fix crash in hwss_set_output_transfer_func()

PATCH Applied Timur Kristóf 3 participants 3 messages Aug 3 – Aug 5

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Fix crash in hwss_set_output_transfer_func()

The pipe_ctx->plane_res.hubp pointer is NULL on all DCE hardware, which causes a kernel NULL pointer dereference on all Vega and older GPUs.

Let's add a simple NULL check.

Fixes f879f53407f0 ("drm/amd/display: Refactor DPP_SET_OUTPUT_TRANSFER_FUNC to drop pipe_ctx")
Cc Tomasz Siemek <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +2 -1
index 11411fa94665..5495e493b2eb 100644
@@ -1900,7 +1900,8 @@ void hwss_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx)
 				.xfm = pipe_ctx->plane_res.xfm,
 				.dpp = pipe_ctx->plane_res.dpp,
 				.mpc = dc->res_pool->mpc,
-				.mpcc_id = pipe_ctx->plane_res.hubp->inst,
+				.mpcc_id = pipe_ctx->plane_res.hubp ?
+						pipe_ctx->plane_res.hubp->inst : 0,
 				.is_top_pipe = resource_is_pipe_type(pipe_ctx, OPP_HEAD),
 				.stream = pipe_ctx->stream,
 			}
Signature · 1 line
2.55.0
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Timur Kristóf

The pipe_ctx->plane_res.hubp pointer is NULL on all DCE hardware, which causes a kernel NULL pointer dereference on all Vega and older GPUs.

Let's add a simple NULL check.

Fixes f879f53407f0 ("drm/amd/display: Refactor DPP_SET_OUTPUT_TRANSFER_FUNC to drop pipe_ctx")
Cc Tomasz Siemek <[email protected]>

I've tested this patch (applied to amd-staging-drm-next) because I observed the crash during my tests for
https://gitlab.freedesktop.org/drm/amd/-/work_items/5557 and I confirm that the patch fixes the crash.

Quoted 18 lines
---
 drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +2 -1
index 11411fa94665..5495e493b2eb 100644
@@ -1900,7 +1900,8 @@ void hwss_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx)
 				.xfm = pipe_ctx->plane_res.xfm,
 				.dpp = pipe_ctx->plane_res.dpp,
 				.mpc = dc->res_pool->mpc,
-				.mpcc_id = pipe_ctx->plane_res.hubp->inst,
+				.mpcc_id = pipe_ctx->plane_res.hubp ?
+						pipe_ctx->plane_res.hubp->inst : 0,
 				.is_top_pipe = resource_is_pipe_type(pipe_ctx, OPP_HEAD),
 				.stream = pipe_ctx->stream,
 			}
Applied
#2 lore raw
In reply to Timur Kristóf

Applied. Thanks!

Quoted 31 lines · Timur Kristóf

The pipe_ctx->plane_res.hubp pointer is NULL on all DCE hardware, which causes a kernel NULL pointer dereference on all Vega and older GPUs.

Let's add a simple NULL check.

Fixes f879f53407f0 ("drm/amd/display: Refactor DPP_SET_OUTPUT_TRANSFER_FUNC to drop pipe_ctx")
Cc Tomasz Siemek <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +2 -2
index 11411fa94665..5495e493b2eb 100644
@@ -1900,7 +1900,8 @@ void hwss_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx)
                                .xfm = pipe_ctx->plane_res.xfm,
                                .dpp = pipe_ctx->plane_res.dpp,
                                .mpc = dc->res_pool->mpc,
-                               .mpcc_id = pipe_ctx->plane_res.hubp->inst,
+                               .mpcc_id = pipe_ctx->plane_res.hubp ?
+                                               pipe_ctx->plane_res.hubp->inst : 0,
                                .is_top_pipe = resource_is_pipe_type(pipe_ctx, OPP_HEAD),
                                .stream = pipe_ctx->stream,
                        }
--

2.55.0