]> www.infradead.org Git - linux.git/commitdiff
drm/amdgpu: fix UBSAN warning in kv_dpm.c
authorAlex Deucher <alexander.deucher@amd.com>
Mon, 20 May 2024 13:05:21 +0000 (09:05 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 19 Jun 2024 22:25:52 +0000 (18:25 -0400)
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
drivers/gpu/drm/amd/pm/legacy-dpm/kv_dpm.c

index 6bb42d04b2479af90a63548dfbafeca633436091..e8b6989a40f35a7b29b4fe5c46c479665fc22e91 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 =