Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/pm: smu7_hwmgr: fix potential off-by-one overflow in 'performance_levels'

Since 'hardwareActivityPerformanceLevels' is set to the size of the
'performance_levels' array in smu7_hwmgr_backend_init(), using the
'<=' assertion to check for the next index value is incorrect.
Replace it with '<'.

Detected using the static analysis tool - Svace.
Fixes: 599a7e9fe1b6 ("drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.")
Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Alexey Kodanev and committed by
Alex Deucher
d2bd0831 2cc4a591

+1 -1
+1 -1
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
··· 3603 3603 return -EINVAL); 3604 3604 3605 3605 PP_ASSERT_WITH_CODE( 3606 - (smu7_power_state->performance_level_count <= 3606 + (smu7_power_state->performance_level_count < 3607 3607 hwmgr->platform_descriptor.hardwareActivityPerformanceLevels), 3608 3608 "Performance levels exceeds Driver limit!", 3609 3609 return -EINVAL);