Skip to content

Commit c5699e2

Browse files
Roman Lialexdeucher
authored andcommitted
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: Lang Yu <[email protected]> Signed-off-by: Roman Li <[email protected]> Reviewed-by: Nicholas Kazlauskas <[email protected]> Acked-by: Qingqing Zhuo <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent dce3d8e commit c5699e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,8 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev)
925925
abm->dmcu_is_running = dmcu->funcs->is_dmcu_initialized(dmcu);
926926
}
927927

928-
adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv);
928+
if (!adev->dm.dc->ctx->dmub_srv)
929+
adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv);
929930
if (!adev->dm.dc->ctx->dmub_srv) {
930931
DRM_ERROR("Couldn't allocate DC DMUB server!\n");
931932
return -ENOMEM;
@@ -1954,7 +1955,6 @@ static int dm_suspend(void *handle)
19541955

19551956
amdgpu_dm_irq_suspend(adev);
19561957

1957-
19581958
dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3);
19591959

19601960
return 0;

0 commit comments

Comments
 (0)