DragonFlyBSD Kernel Audit
DF-1690 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/drm/amd/powerplay/hwmgr/vega20_processpptables.c b/sys/dev/drm/amd/powerplay/hwmgr/vega20_processpptables.c
--- a/sys/dev/drm/amd/powerplay/hwmgr/vega20_processpptables.c
+++ b/sys/dev/drm/amd/powerplay/hwmgr/vega20_processpptables.c
@@ -716,11 +716,16 @@
 	struct atom_smc_dpm_info_v4_4 *smc_dpm_table;
 	int index = GetIndexIntoMasterDataTable(smc_dpm_info);
 	int i;
+	uint16_t table_size;
 
 	PP_ASSERT_WITH_CODE(
-		smc_dpm_table = smu_atom_get_data_table(hwmgr->adev, index, NULL, NULL, NULL),
+		smc_dpm_table = smu_atom_get_data_table(hwmgr->adev, index,
+		    &table_size, NULL, NULL),
 		"[appendVbiosPPTable] Failed to retrieve Smc Dpm Table from VBIOS!",
 		return -1);
+	PP_ASSERT_WITH_CODE(table_size >= sizeof(struct atom_smc_dpm_info_v4_4),
+		"[appendVbiosPPTable] Smc Dpm Table too small!",
+		return -EINVAL);
 
 	ppsmc_pptable->MaxVoltageStepGfx = smc_dpm_table->maxvoltagestepgfx;
 	ppsmc_pptable->MaxVoltageStepSoc = smc_dpm_table->maxvoltagestepsoc;