]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jul 2024 07:08:26 +0000 (09:08 +0200)
[ Upstream commit f0d576f840153392d04b2d52cf3adab8f62e8cb6 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/kv_dpm.c

index 6eb6f05c11367f132d8e394eabbf7133e83fa4b3..56e15f5bc8225253aceac4611006ad5364b19299 100644 (file)
@@ -163,6 +163,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 =