⬢ DragonFlyBSD Kernel Audit
DF-3702 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/sys/dev/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -266,6 +266,9 @@ static int vega10_set_features_platform_
 	struct amdgpu_device *adev = hwmgr->adev;
 
+	PP_ASSERT_WITH_CODE(table_info->tdp_table,
+			"PowerTune table is missing",
+			return -EINVAL);
+
 	if (table_info->tdp_table->usClockStretchAmount &&
 			data->registry_data.clock_stretcher_support)
 		phm_cap_set(hwmgr->platform_descriptor.platformCaps,
@@ -645,6 +648,10 @@ static int vega10_patch_voltage_dependen
 		switch (i) {
 			case 0: vdt = table_info->vdd_dep_on_socclk; break;
@@
 		}
 
+		if (!vdt || !table_info->vddc_lookup_table)
+			continue; /* optional subtable absent in this VBIOS */
+
 		for (entry_id = 0; entry_id < vdt->count; entry_id++) {
 			voltage_id = vdt->entries[entry_id].vddInd;
 			vdt->entries[entry_id].vddc =
@@ -663,12 +670,14 @@ static int vega10_patch_voltage_dependen
-	for (entry_id = 0; entry_id < mm_table->count; ++entry_id) {
+	if (mm_table && table_info->vddc_lookup_table)
+	for (entry_id = 0; entry_id < mm_table->count; ++entry_id) {
 		voltage_id = mm_table->entries[entry_id].vddcInd;
 		mm_table->entries[entry_id].vddc =
 			table_info->vddc_lookup_table->entries[voltage_id].us_vdd;
 	}
 
-	for (entry_id = 0; entry_id < mclk_table->count; ++entry_id) {
+	if (!table_info->vddci_lookup_table || !table_info->vddmem_lookup_table)
+		return -EINVAL; /* mclk patch needs all three lookup tables */
+
+	for (entry_id = 0; entry_id < mclk_table->count; ++entry_id) {
 		voltage_id = mclk_table->entries[entry_id].vddInd;
 		mclk_table->entries[entry_id].vddc =
 				table_info->vddc_lookup_table->entries[voltage_id].us_vdd;