drm/radeon: fix UBSAN warning in kv_dpm.c
authorAlex Deucher <alexander.deucher@amd.com>
Mon, 20 May 2024 13:11:45 +0000 (09:11 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 19 Jun 2024 22:25:37 +0000 (18:25 -0400)
Adds bounds check for sumo_vid_mapping_entry.

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/radeon/sumo_dpm.c

index 21d27e6..b11f7c5 100644 (file)
@@ -1619,6 +1619,8 @@ void sumo_construct_vid_mapping_table(struct radeon_device *rdev,
 
        for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++) {
                if (table[i].ulSupportedSCLK != 0) {
+                       if (table[i].usVoltageIndex >= SUMO_MAX_NUMBER_VOLTAGES)
+                               continue;
                        vid_mapping_table->entries[table[i].usVoltageIndex].vid_7bit =
                                table[i].usVoltageID;
                        vid_mapping_table->entries[table[i].usVoltageIndex].vid_2bit =