drm/radeon: fix UBSAN warning in kv_dpm.c
authorjsg <jsg@openbsd.org>
Fri, 28 Jun 2024 03:35:06 +0000 (03:35 +0000)
committerjsg <jsg@openbsd.org>
Fri, 28 Jun 2024 03:35:06 +0000 (03:35 +0000)
From Alex Deucher
9e57611182a817824a17b1c3dd300ee74a174b42 in linux-6.6.y/6.6.36
a498df5421fd737d11bfd152428ba6b1c8538321 in mainline linux

sys/dev/pci/drm/radeon/sumo_dpm.c

index d49c145..f7f1ddc 100644 (file)
@@ -1621,6 +1621,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 =