Commit 67bef0f7 authored by Huang Rui's avatar Huang Rui Committed by Alex Deucher

drm/amdgpu: fix the memory corruption on S3

psp->cmd will be used on resume phase, so we can not free it on hw_init.
Otherwise, a memory corruption will be triggered.
Signed-off-by: default avatarHuang Rui <ray.huang@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Tested-by: default avatarXiaojie Yuan <Xiaojie.Yuan@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
parent 6b0fa871
...@@ -333,14 +333,11 @@ static int psp_load_fw(struct amdgpu_device *adev) ...@@ -333,14 +333,11 @@ static int psp_load_fw(struct amdgpu_device *adev)
{ {
int ret; int ret;
struct psp_context *psp = &adev->psp; struct psp_context *psp = &adev->psp;
struct psp_gfx_cmd_resp *cmd;
cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL); psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
if (!cmd) if (!psp->cmd)
return -ENOMEM; return -ENOMEM;
psp->cmd = cmd;
ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG, ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
AMDGPU_GEM_DOMAIN_GTT, AMDGPU_GEM_DOMAIN_GTT,
&psp->fw_pri_bo, &psp->fw_pri_bo,
...@@ -379,8 +376,6 @@ static int psp_load_fw(struct amdgpu_device *adev) ...@@ -379,8 +376,6 @@ static int psp_load_fw(struct amdgpu_device *adev)
if (ret) if (ret)
goto failed_mem; goto failed_mem;
kfree(cmd);
return 0; return 0;
failed_mem: failed_mem:
...@@ -390,7 +385,8 @@ static int psp_load_fw(struct amdgpu_device *adev) ...@@ -390,7 +385,8 @@ static int psp_load_fw(struct amdgpu_device *adev)
amdgpu_bo_free_kernel(&psp->fw_pri_bo, amdgpu_bo_free_kernel(&psp->fw_pri_bo,
&psp->fw_pri_mc_addr, &psp->fw_pri_buf); &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
failed: failed:
kfree(cmd); kfree(psp->cmd);
psp->cmd = NULL;
return ret; return ret;
} }
...@@ -450,6 +446,9 @@ static int psp_hw_fini(void *handle) ...@@ -450,6 +446,9 @@ static int psp_hw_fini(void *handle)
amdgpu_bo_free_kernel(&psp->fence_buf_bo, amdgpu_bo_free_kernel(&psp->fence_buf_bo,
&psp->fence_buf_mc_addr, &psp->fence_buf); &psp->fence_buf_mc_addr, &psp->fence_buf);
kfree(psp->cmd);
psp->cmd = NULL;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment