]> www.infradead.org Git - nvme.git/commitdiff
drm/amd/display: Fix array-index-out-of-bounds in dml2/FCLKChangeSupport
authorRoman Li <Roman.Li@amd.com>
Wed, 26 Jun 2024 18:08:41 +0000 (14:08 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 1 Jul 2024 20:53:24 +0000 (16:53 -0400)
[Why]
Potential out of bounds access in dml2_calculate_rq_and_dlg_params()
because the value of out_lowest_state_idx used as an index for FCLKChangeSupport
array can be greater than 1.

[How]
Currently dml2 core specifies identical values for all FCLKChangeSupport
elements. Always use index 0 in the condition to avoid out of bounds access.

Acked-by: Rodrigo Siqueira <rodrigo.siqueira@amd.com>
Signed-off-by: Jerry Zuo <jerry.zuo@amd.com>
Signed-off-by: Roman Li <Roman.Li@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dml2/dml2_utils.c

index 0f8b3336e26d56367f2c99c15a1baa8ab0d6b379..cbd1c1f26b7a5542bc018b01e8af1ccd591013cd 100644 (file)
@@ -294,7 +294,7 @@ void dml2_calculate_rq_and_dlg_params(const struct dc *dc, struct dc_state *cont
        context->bw_ctx.bw.dcn.clk.dcfclk_deep_sleep_khz = (unsigned int)in_ctx->v20.dml_core_ctx.mp.DCFCLKDeepSleep * 1000;
        context->bw_ctx.bw.dcn.clk.dppclk_khz = 0;
 
-       if (in_ctx->v20.dml_core_ctx.ms.support.FCLKChangeSupport[in_ctx->v20.scratch.mode_support_params.out_lowest_state_idx] == dml_fclock_change_unsupported)
+       if (in_ctx->v20.dml_core_ctx.ms.support.FCLKChangeSupport[0] == dml_fclock_change_unsupported)
                context->bw_ctx.bw.dcn.clk.fclk_p_state_change_support = false;
        else
                context->bw_ctx.bw.dcn.clk.fclk_p_state_change_support = true;