⬢ DragonFlyBSD Kernel Audit
DF-4291 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/amd/powerplay/hwmgr/ppatomctrl.c
+++ b/sys/dev/drm/amd/powerplay/hwmgr/ppatomctrl.c
@@ -1126,6 +1126,12 @@ int atomctrl_get_voltage_evv(struct pp_hwmgr *hwmgr,
 	GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_2 get_voltage_info_param_space;
 	int result;
 	int entry_id;
+	struct phm_clock_voltage_dependency_table *vddc_on_sclk =
+			hwmgr->dyn_state.vddc_dependency_on_sclk;
+
+	if (vddc_on_sclk == NULL) {
+		pr_debug("No vddc_dependency_on_sclk table in PowerPlay table!\n");
+		return -EINVAL;
+	}
 
 	/* search for leakage voltage ID 0xff01 ~ 0xff08 and sckl */
-	for (entry_id = 0; entry_id < hwmgr->dyn_state.vddc_dependency_on_sclk->count; entry_id++) {
-		if (hwmgr->dyn_state.vddc_dependency_on_sclk->entries[entry_id].v == virtual_voltage_id) {
+	for (entry_id = 0; entry_id < vddc_on_sclk->count; entry_id++) {
+		if (vddc_on_sclk->entries[entry_id].v == virtual_voltage_id) {
 			/* found */
 			break;
 		}
 	}
 
-	if (entry_id >= hwmgr->dyn_state.vddc_dependency_on_sclk->count) {
+	if (entry_id >= vddc_on_sclk->count) {
 	        pr_debug("Can't find requested voltage id in vddc_dependency_on_sclk table!\n");
 	        return -EINVAL;
 	}
@@ -1146,7 +1152,7 @@
 	get_voltage_info_param_space.ulSCLKFreq =
-		cpu_to_le32(hwmgr->dyn_state.vddc_dependency_on_sclk->entries[entry_id].clk);
+		cpu_to_le32(vddc_on_sclk->entries[entry_id].clk);