⬢ DragonFlyBSD Kernel Audit
DF-3685 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/sys/dev/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -1855,6 +1855,14 @@
 	struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_table =
 			table_info->mm_dep_table;
 
+	if (sclk_table == NULL || mclk_table == NULL || mm_table == NULL ||
+	    table_info->vddc_lookup_table == NULL ||
+	    (data->vdd_gfx_control == SMU7_VOLTAGE_CONTROL_BY_SVID2 &&
+	     table_info->vddgfx_lookup_table == NULL)) {
+		pr_err("smu7: mandatory V1 dependency/lookup subtable missing\n");
+		return -EINVAL;
+	}
+
 	if (data->vdd_gfx_control == SMU7_VOLTAGE_CONTROL_BY_SVID2) {
 		for (entry_id = 0; entry_id < sclk_table->count; ++entry_id) {
 			voltage_id = sclk_table->entries[entry_id].vddInd;
@@ -2180,7 +2188,8 @@
 	if (table_info == NULL)
 		return 0;
 
-	if (table_info->cac_dtp_table->usDefaultTargetOperatingTemp != 0 &&
+	if (table_info->cac_dtp_table != NULL &&
+		table_info->cac_dtp_table->usDefaultTargetOperatingTemp != 0 &&
 		hwmgr->thermal_controller.advanceFanControlParameters.ucFanControlMode) {
 		hwmgr->thermal_controller.advanceFanControlParameters.usFanPWMMinLimit =
 			(uint16_t)hwmgr->thermal_controller.advanceFanControlParameters.ucMinimumPWMLimit;
@@ -2558,8 +2567,11 @@
 	}
 
 	if (hwmgr->pp_table_version == PP_TABLE_V1) {
-		smu7_complete_dependency_tables(hwmgr);
-		smu7_set_private_data_based_on_pptable_v1(hwmgr);
+		result = smu7_complete_dependency_tables(hwmgr);
+		if (!result)
+			result = smu7_set_private_data_based_on_pptable_v1(hwmgr);
+		if (result)
+			return result;	/* fail load instead of limping on */
 	} else if (hwmgr->pp_table_version == PP_TABLE_V0) {
 		smu7_patch_dependency_tables_with_leakage(hwmgr);
 		smu7_set_private_data_based_on_pptable_v0(hwmgr);
@@ -4760,7 +4772,7 @@
 
 	memcpy(thermal_data, &SMU7ThermalPolicy[0], sizeof(struct PP_TemperatureRange));
 
-	if (hwmgr->pp_table_version == PP_TABLE_V1)
+	if (hwmgr->pp_table_version == PP_TABLE_V1 && table_info->cac_dtp_table != NULL)
 		thermal_data->max = table_info->cac_dtp_table->usSoftwareShutdownTemp *
 			PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
 	else if (hwmgr->pp_table_version == PP_TABLE_V0)