]> git.ipfire.org Git - thirdparty/linux.git/commit
drm/amd/display: Fix possible buffer overflow in 'find_dcfclk_for_voltage()'
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Mon, 5 Feb 2024 11:24:10 +0000 (16:54 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 15 Feb 2024 19:18:43 +0000 (14:18 -0500)
commitccc514b7e7acbd301219cbaec0fc0bfe5741acee
tree8f481cf1413e4cc833b9fe00250bcd6443a9fa26
parent88c6d84dd8f70e498f89972449e6ebb7aa1309c0
drm/amd/display: Fix possible buffer overflow in 'find_dcfclk_for_voltage()'

when 'find_dcfclk_for_voltage()' function is looping over
VG_NUM_SOC_VOLTAGE_LEVELS (which is 8), but the size of the DcfClocks
array is VG_NUM_DCFCLK_DPM_LEVELS (which is 7).

When the loop variable i reaches 7, the function tries to access
clock_table->DcfClocks[7]. However, since the size of the DcfClocks
array is 7, the valid indices are 0 to 6. Index 7 is beyond the size of
the array, leading to a buffer overflow.

Reported by smatch & thus fixing the below:
drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/dcn301/vg_clk_mgr.c:550 find_dcfclk_for_voltage() error: buffer overflow 'clock_table->DcfClocks' 7 <= 7

Fixes: 3a83e4e64bb1 ("drm/amd/display: Add dcn3.01 support to DC (v2)")
Cc: Roman Li <Roman.Li@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Roman Li <roman.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c