Skip to content

Commit f0d576f

Browse files
committed
drm/amdgpu: fix UBSAN warning in kv_dpm.c
Adds bounds check for sumo_vid_mapping_entry. Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3392 Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
1 parent a498df5 commit f0d576f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • drivers/gpu/drm/amd/pm/legacy-dpm

drivers/gpu/drm/amd/pm/legacy-dpm/kv_dpm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ static void sumo_construct_vid_mapping_table(struct amdgpu_device *adev,
164164

165165
for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++) {
166166
if (table[i].ulSupportedSCLK != 0) {
167+
if (table[i].usVoltageIndex >= SUMO_MAX_NUMBER_VOLTAGES)
168+
continue;
167169
vid_mapping_table->entries[table[i].usVoltageIndex].vid_7bit =
168170
table[i].usVoltageID;
169171
vid_mapping_table->entries[table[i].usVoltageIndex].vid_2bit =

0 commit comments

Comments
 (0)