Release the memory (psp->cmd) when psp initialization is failed in psp_sw_init
Signed-off-by: Ma Jun <jun....@amd.com> Change-Id: I2f88b5919142d55dd7d3820a7da94823286db235 --- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index a6acec1a6155..1227dc014c80 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -305,9 +305,10 @@ static int psp_sw_init(void *handle) ret = psp_init_sriov_microcode(psp); else ret = psp_init_microcode(psp); + if (ret) { DRM_ERROR("Failed to load psp firmware!\n"); - return ret; + goto failure; } adev->psp.xgmi_context.supports_extended_data = @@ -339,25 +340,27 @@ static int psp_sw_init(void *handle) ret = psp_memory_training_init(psp); if (ret) { DRM_ERROR("Failed to initialize memory training!\n"); - return ret; + goto failure; } ret = psp_mem_training(psp, PSP_MEM_TRAIN_COLD_BOOT); if (ret) { DRM_ERROR("Failed to process memory training!\n"); - return ret; + goto failure; } } if (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 0) || adev->ip_versions[MP0_HWIP][0] == IP_VERSION(11, 0, 7)) { ret= psp_sysfs_init(adev); - if (ret) { - return ret; - } + if (ret) + goto failure; } return 0; +failure: + kfree(psp->cmd); + return ret; } static int psp_sw_fini(void *handle) -- 2.25.1