]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/amd/powerplay: avoid access before allocation
authorEvan Quan <evan.quan@amd.com>
Fri, 12 Jul 2019 02:32:02 +0000 (10:32 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 17 Jul 2019 18:34:30 +0000 (13:34 -0500)
No access before allocation.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Feifei Xu <Feifei.Xu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/vega20_ppt.c

index 3c605257b89cdfada807e59a16c6f190c7b7591a..6d267aeacda37072a201a45006a3db41fc66ea70 100644 (file)
@@ -441,7 +441,6 @@ static int vega20_store_powerplay_table(struct smu_context *smu)
 {
        ATOM_Vega20_POWERPLAYTABLE *powerplay_table = NULL;
        struct smu_table_context *table_context = &smu->smu_table;
-       int ret;
 
        if (!table_context->power_play_table)
                return -EINVAL;
@@ -455,9 +454,7 @@ static int vega20_store_powerplay_table(struct smu_context *smu)
        table_context->thermal_controller_type = powerplay_table->ucThermalControllerType;
        table_context->TDPODLimit = le32_to_cpu(powerplay_table->OverDrive8Table.ODSettingsMax[ATOM_VEGA20_ODSETTING_POWERPERCENTAGE]);
 
-       ret = vega20_setup_od8_information(smu);
-
-       return ret;
+       return 0;
 }
 
 static int vega20_append_powerplay_table(struct smu_context *smu)
@@ -1507,6 +1504,12 @@ static int vega20_set_default_od8_setttings(struct smu_context *smu)
 
        smu->od_settings = (void *)od8_settings;
 
+       ret = vega20_setup_od8_information(smu);
+       if (ret) {
+               pr_err("Retrieve board OD limits failed!\n");
+               return ret;
+       }
+
        if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_SOCCLK_BIT)) {
                if (od8_settings->od_feature_capabilities[ATOM_VEGA20_ODFEATURE_GFXCLK_LIMITS] &&
                    od8_settings->od_settings_max[OD8_SETTING_GFXCLK_FMAX] > 0 &&