]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: fix buffer overruns warnings
authorGaghik Khachatrian <gaghik.khachatrian@amd.com>
Thu, 23 Apr 2026 02:12:25 +0000 (22:12 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 5 May 2026 13:56:53 +0000 (09:56 -0400)
[Why & How]
Fixes a warning by adding bounds checks and index validation in dml2_0
sources to address static analysis warnings. Ensures safe array access and
prevents out-of-bounds reads by validating indices before use, improving
robustness and reliability in the affected files.

Reviewed-by: Austin Zheng <austin.zheng@amd.com>
Signed-off-by: Gaghik Khachatrian <gaghik.khachatrian@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_mcg/dml2_mcg_dcn42.c

index 3eaeff39ee792eb08c229903b4e8b1401ff2e408..ef8b75fed9a3eac56f66ba5401d9f3528e4fec8e 100644 (file)
@@ -22,7 +22,7 @@ static bool build_min_clk_table_coarse_grained(const struct dml2_soc_bb *soc_bb,
                        min_table->dram_bw_table.entries[i].pre_derate_dram_bw_kbps =
                                        uclk_to_dram_bw_kbps(soc_bb->clk_table.uclk.clk_values_khz[i], &soc_bb->clk_table.dram_config, soc_bb->clk_table.wck_ratio.clk_values_khz[i]);
                        min_table->dram_bw_table.entries[i].min_uclk_khz = soc_bb->clk_table.uclk.clk_values_khz[i];
-               } else {
+               } else if (soc_bb->clk_table.uclk.num_clk_values > 0) {
                        min_table->dram_bw_table.entries[i].pre_derate_dram_bw_kbps = min_table->dram_bw_table.entries[soc_bb->clk_table.uclk.num_clk_values - 1].pre_derate_dram_bw_kbps;
                        min_table->dram_bw_table.entries[i].min_uclk_khz = soc_bb->clk_table.uclk.clk_values_khz[soc_bb->clk_table.uclk.num_clk_values - 1];
                }