Commit 5e91160a authored by Guchun Chen's avatar Guchun Chen Committed by Alex Deucher

drm/amdgpu: fix RAS memory leak in error case

RAS context memory needs to freed in failure case.
Signed-off-by: default avatarGuchun Chen <guchun.chen@amd.com>
Reviewed-by: default avatarTao Zhou <tao.zhou1@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d43f7ff6
...@@ -1917,9 +1917,8 @@ int amdgpu_ras_init(struct amdgpu_device *adev) ...@@ -1917,9 +1917,8 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
amdgpu_ras_check_supported(adev, &con->hw_supported, amdgpu_ras_check_supported(adev, &con->hw_supported,
&con->supported); &con->supported);
if (!con->hw_supported) { if (!con->hw_supported) {
amdgpu_ras_set_context(adev, NULL); r = 0;
kfree(con); goto err_out;
return 0;
} }
con->features = 0; con->features = 0;
...@@ -1930,29 +1929,31 @@ int amdgpu_ras_init(struct amdgpu_device *adev) ...@@ -1930,29 +1929,31 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
if (adev->nbio.funcs->init_ras_controller_interrupt) { if (adev->nbio.funcs->init_ras_controller_interrupt) {
r = adev->nbio.funcs->init_ras_controller_interrupt(adev); r = adev->nbio.funcs->init_ras_controller_interrupt(adev);
if (r) if (r)
return r; goto err_out;
} }
if (adev->nbio.funcs->init_ras_err_event_athub_interrupt) { if (adev->nbio.funcs->init_ras_err_event_athub_interrupt) {
r = adev->nbio.funcs->init_ras_err_event_athub_interrupt(adev); r = adev->nbio.funcs->init_ras_err_event_athub_interrupt(adev);
if (r) if (r)
return r; goto err_out;
} }
amdgpu_ras_mask &= AMDGPU_RAS_BLOCK_MASK; amdgpu_ras_mask &= AMDGPU_RAS_BLOCK_MASK;
if (amdgpu_ras_fs_init(adev)) if (amdgpu_ras_fs_init(adev)) {
goto fs_out; r = -EINVAL;
goto err_out;
}
dev_info(adev->dev, "RAS INFO: ras initialized successfully, " dev_info(adev->dev, "RAS INFO: ras initialized successfully, "
"hardware ability[%x] ras_mask[%x]\n", "hardware ability[%x] ras_mask[%x]\n",
con->hw_supported, con->supported); con->hw_supported, con->supported);
return 0; return 0;
fs_out: err_out:
amdgpu_ras_set_context(adev, NULL); amdgpu_ras_set_context(adev, NULL);
kfree(con); kfree(con);
return -EINVAL; return r;
} }
/* helper function to handle common stuff in ip late init phase */ /* helper function to handle common stuff in ip late init phase */
......
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