From 279234558b8f4e04397d233c94ab5bdae737202c Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 9 Sep 2024 09:02:02 +0000 Subject: [PATCH] drm/amd/display: Ensure index calculation will not overflow From Alex Hung 3dc6bb57dab36b38b7374af0ac916174c146b6ed in linux-6.6.y/6.6.50 8e2734bf444767fed787305ccdcb36a2be5301a2 in mainline linux --- sys/dev/pci/drm/amd/display/dc/dml/calcs/dcn_calcs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/drm/amd/display/dc/dml/calcs/dcn_calcs.c b/sys/dev/pci/drm/amd/display/dc/dml/calcs/dcn_calcs.c index 50b0434354f..c08169de366 100644 --- a/sys/dev/pci/drm/amd/display/dc/dml/calcs/dcn_calcs.c +++ b/sys/dev/pci/drm/amd/display/dc/dml/calcs/dcn_calcs.c @@ -1453,10 +1453,9 @@ void dcn_bw_update_from_pplib_fclks( ASSERT(fclks->num_levels); vmin0p65_idx = 0; - vmid0p72_idx = fclks->num_levels - - (fclks->num_levels > 2 ? 3 : (fclks->num_levels > 1 ? 2 : 1)); - vnom0p8_idx = fclks->num_levels - (fclks->num_levels > 1 ? 2 : 1); - vmax0p9_idx = fclks->num_levels - 1; + vmid0p72_idx = fclks->num_levels > 2 ? fclks->num_levels - 3 : 0; + vnom0p8_idx = fclks->num_levels > 1 ? fclks->num_levels - 2 : 0; + vmax0p9_idx = fclks->num_levels > 0 ? fclks->num_levels - 1 : 0; dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 = 32 * (fclks->data[vmin0p65_idx].clocks_in_khz / 1000.0) / 1000.0; -- 2.20.1