lkml.org 
[lkml]   [2021]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.10 33/38] drm/amd/display: Fix potential memory leak in DMUB hw_init
    Date
    From: Roman Li <roman.li@amd.com>

    [ Upstream commit c5699e2d863f58221044efdc3fa712dd32d55cde ]

    [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 <Lang.Yu@amd.com>
    Signed-off-by: Roman Li <roman.li@amd.com>
    Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
    Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
    Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
    index 4792228ed481..13588c46ae8e 100644
    --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
    +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
    @@ -870,7 +870,8 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev)
    abm->dmcu_is_running = dmcu->funcs->is_dmcu_initialized(dmcu);
    }

    - adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv);
    + 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");
    return -ENOMEM;
    @@ -1755,7 +1756,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;
    --
    2.30.2


    \
     
     \ /
      Last update: 2021-06-16 17:39    [W:4.237 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site