Skip to content

Commit

Permalink
drm/amdgpu: fix potential memory leak during navi12 deinitialization
Browse files Browse the repository at this point in the history
[ Upstream commit e6d5c64 ]

Navi12 HDCP & DTM deinitialization needs continue to free bo if already
created though initialized flag is not set.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jiawei Gu <Jiawei.Gu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Jiawei Gu authored and gregkh committed Jan 19, 2021
1 parent 9910f52 commit 279af87
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
Expand Up @@ -1283,15 +1283,20 @@ static int psp_hdcp_terminate(struct psp_context *psp)
if (amdgpu_sriov_vf(psp->adev))
return 0;

if (!psp->hdcp_context.hdcp_initialized)
return 0;
if (!psp->hdcp_context.hdcp_initialized) {
if (psp->hdcp_context.hdcp_shared_buf)
goto out;
else
return 0;
}

ret = psp_hdcp_unload(psp);
if (ret)
return ret;

psp->hdcp_context.hdcp_initialized = false;

out:
/* free hdcp shared memory */
amdgpu_bo_free_kernel(&psp->hdcp_context.hdcp_shared_bo,
&psp->hdcp_context.hdcp_shared_mc_addr,
Expand Down Expand Up @@ -1430,15 +1435,20 @@ static int psp_dtm_terminate(struct psp_context *psp)
if (amdgpu_sriov_vf(psp->adev))
return 0;

if (!psp->dtm_context.dtm_initialized)
return 0;
if (!psp->dtm_context.dtm_initialized) {
if (psp->dtm_context.dtm_shared_buf)
goto out;
else
return 0;
}

ret = psp_dtm_unload(psp);
if (ret)
return ret;

psp->dtm_context.dtm_initialized = false;

out:
/* free hdcp shared memory */
amdgpu_bo_free_kernel(&psp->dtm_context.dtm_shared_bo,
&psp->dtm_context.dtm_shared_mc_addr,
Expand Down

0 comments on commit 279af87

Please sign in to comment.