drm/amd/powerplay: suppress KASAN out of bounds warning in vega10_populate_all_memory...
authorEvan Quan <evan.quan@amd.com>
Mon, 6 Nov 2017 02:33:45 +0000 (10:33 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 7 Nov 2017 21:40:26 +0000 (16:40 -0500)
Signed-off-by: Evan Quan <evan.quan@amd.com>
Tested-and-Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c

index 4239b98..b66df60 100644 (file)
@@ -1807,6 +1807,10 @@ static int vega10_populate_all_memory_levels(struct pp_hwmgr *hwmgr)
        mem_channels = (cgs_read_register(hwmgr->device, reg) &
                        DF_CS_AON0_DramBaseAddress0__IntLvNumChan_MASK) >>
                        DF_CS_AON0_DramBaseAddress0__IntLvNumChan__SHIFT;
+       PP_ASSERT_WITH_CODE(mem_channels < ARRAY_SIZE(channel_number),
+                       "Mem Channel Index Exceeded maximum!",
+                       return -1);
+
        pp_table->NumMemoryChannels = cpu_to_le16(mem_channels);
        pp_table->MemoryChannelWidth =
                        cpu_to_le16(HBM_MEMORY_CHANNEL_WIDTH *