Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d8f086c authored by Monk Liu's avatar Monk Liu Committed by Alex Deucher
Browse files

drm/amdgpu: fix memleak in pptable_init

parent 89e0ec9f
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -73,11 +73,14 @@ static int pp_sw_init(void *handle)

	ret = hwmgr->hwmgr_func->backend_init(hwmgr);
	if (ret)
		goto err;
		goto err1;

	pr_info("amdgpu: powerplay initialized\n");

	return 0;
err1:
	if (hwmgr->pptable_func->pptable_fini)
		hwmgr->pptable_func->pptable_fini(hwmgr);
err:
	pr_err("amdgpu: powerplay initialization failed\n");
	return ret;
@@ -100,6 +103,9 @@ static int pp_sw_fini(void *handle)
	if (hwmgr->hwmgr_func->backend_fini != NULL)
		ret = hwmgr->hwmgr_func->backend_fini(hwmgr);

	if (hwmgr->pptable_func->pptable_fini)
		hwmgr->pptable_func->pptable_fini(hwmgr);

	return ret;
}

+25 −29
Original line number Diff line number Diff line
@@ -1040,48 +1040,44 @@ int tonga_pp_tables_uninitialize(struct pp_hwmgr *hwmgr)
	struct phm_ppt_v1_information *pp_table_information =
		(struct phm_ppt_v1_information *)(hwmgr->pptable);

	if (NULL != hwmgr->soft_pp_table) {
		kfree(hwmgr->soft_pp_table);
	if (NULL != hwmgr->soft_pp_table)
		hwmgr->soft_pp_table = NULL;
	}

	if (NULL != pp_table_information->vdd_dep_on_sclk)
	kfree(pp_table_information->vdd_dep_on_sclk);
	pp_table_information->vdd_dep_on_sclk = NULL;

	if (NULL != pp_table_information->vdd_dep_on_mclk)
	kfree(pp_table_information->vdd_dep_on_mclk);
	pp_table_information->vdd_dep_on_mclk = NULL;

	if (NULL != pp_table_information->valid_mclk_values)
	kfree(pp_table_information->valid_mclk_values);
	pp_table_information->valid_mclk_values = NULL;

	if (NULL != pp_table_information->valid_sclk_values)
	kfree(pp_table_information->valid_sclk_values);
	pp_table_information->valid_sclk_values = NULL;

	if (NULL != pp_table_information->vddc_lookup_table)
	kfree(pp_table_information->vddc_lookup_table);
	pp_table_information->vddc_lookup_table = NULL;

	if (NULL != pp_table_information->vddgfx_lookup_table)
	kfree(pp_table_information->vddgfx_lookup_table);
	pp_table_information->vddgfx_lookup_table = NULL;

	if (NULL != pp_table_information->mm_dep_table)
	kfree(pp_table_information->mm_dep_table);
	pp_table_information->mm_dep_table = NULL;

	if (NULL != pp_table_information->cac_dtp_table)
	kfree(pp_table_information->cac_dtp_table);
	pp_table_information->cac_dtp_table = NULL;

	if (NULL != hwmgr->dyn_state.cac_dtp_table)
	kfree(hwmgr->dyn_state.cac_dtp_table);
	hwmgr->dyn_state.cac_dtp_table = NULL;

	if (NULL != pp_table_information->ppm_parameter_table)
	kfree(pp_table_information->ppm_parameter_table);
	pp_table_information->ppm_parameter_table = NULL;

	if (NULL != pp_table_information->pcie_table)
	kfree(pp_table_information->pcie_table);
	pp_table_information->pcie_table = NULL;

	if (NULL != hwmgr->pptable) {
	kfree(hwmgr->pptable);
	hwmgr->pptable = NULL;
	}

	return result;
}