Commit 051b7887 authored by Roman Li's avatar Roman Li Committed by Alex Deucher
Browse files

drm/amd/display: Fix potential memory leak in DMUB hw_init



[Why]
On resume we perform DMUB hw_init which allocates memory:
dm_resume->dm_dmub_hw_init->dc_dmub_srv_create->kzalloc
That results in memory leak in suspend/resume scenarios.

[How]
Allocate memory for the DC wrapper to DMUB only if it was not
allocated before.
No need to reallocate it on suspend/resume.

Signed-off-by: default avatarLang Yu <Lang.Yu@amd.com>
Signed-off-by: default avatarRoman Li <roman.li@amd.com>
Reviewed-by: default avatarNicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
Acked-by: default avatarQingqing Zhuo <qingqing.zhuo@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 3beac533
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -982,6 +982,7 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev)
		abm->dmcu_is_running = dmcu->funcs->is_dmcu_initialized(dmcu);
	}

	if (!adev->dm.dc->ctx->dmub_srv)
		adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv);
	if (!adev->dm.dc->ctx->dmub_srv) {
		DRM_ERROR("Couldn't allocate DC DMUB server!\n");
@@ -2003,7 +2004,6 @@ static int dm_suspend(void *handle)

	amdgpu_dm_irq_suspend(adev);


	dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3);

	return 0;