drm/amdgpu: fix UBSAN warning in kv_dpm.c
authorjsg <jsg@openbsd.org>
Fri, 28 Jun 2024 03:37:58 +0000 (03:37 +0000)
committerjsg <jsg@openbsd.org>
Fri, 28 Jun 2024 03:37:58 +0000 (03:37 +0000)
From Alex Deucher
b065d79ed06a0bb4377bc6dcc2ff0cb1f55a798f in linux-6.6.y/6.6.36
f0d576f840153392d04b2d52cf3adab8f62e8cb6 in mainline linux

sys/dev/pci/drm/amd/pm/legacy-dpm/amdgpu_kv_dpm.c

index 5cb4725..c8586cb 100644 (file)
@@ -164,6 +164,8 @@ static void sumo_construct_vid_mapping_table(struct amdgpu_device *adev,
 
        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 =