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

drm/amd/powerplay: avoid out of bounds access on array ps.

check array index first and then visit the array.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Rex Zhu and committed by
Alex Deucher
da7800a8 1da2c326

+6 -6
+6 -6
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
··· 2984 2984 if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk) 2985 2985 data->highest_mclk = memory_clock; 2986 2986 2987 - performance_level = &(ps->performance_levels 2988 - [ps->performance_level_count++]); 2989 - 2990 2987 PP_ASSERT_WITH_CODE( 2991 2988 (ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)), 2992 2989 "Performance levels exceeds SMC limit!", 2993 2990 return -EINVAL); 2994 2991 2995 2992 PP_ASSERT_WITH_CODE( 2996 - (ps->performance_level_count <= 2993 + (ps->performance_level_count < 2997 2994 hwmgr->platform_descriptor.hardwareActivityPerformanceLevels), 2998 - "Performance levels exceeds Driver limit!", 2999 - return -EINVAL); 2995 + "Performance levels exceeds Driver limit, Skip!", 2996 + return 0); 2997 + 2998 + performance_level = &(ps->performance_levels 2999 + [ps->performance_level_count++]); 3000 3000 3001 3001 /* Performance levels are arranged from low to high. */ 3002 3002 performance_level->memory_clock = memory_clock;