drm/amdgpu/powerplay/vega10: fix memory leak in error path
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 14 Mar 2018 01:43:00 +0000 (20:43 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 14 Mar 2018 21:01:18 +0000 (16:01 -0500)
Free the backend structure if we fail to allocate device
memory.

Reviewed-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c

index 15e1afa..2199508 100644 (file)
@@ -406,9 +406,8 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
                        &handle,
                        &mc_addr,
                        &kaddr);
-
        if (ret)
-               return -EINVAL;
+               goto free_backend;
 
        priv->smu_tables.entry[PPTABLE].version = 0x01;
        priv->smu_tables.entry[PPTABLE].size = sizeof(PPTable_t);
@@ -511,6 +510,9 @@ err0:
        amdgpu_bo_free_kernel(&priv->smu_tables.entry[PPTABLE].handle,
                        &priv->smu_tables.entry[PPTABLE].mc_addr,
                        &priv->smu_tables.entry[PPTABLE].table);
+free_backend:
+       kfree(hwmgr->smu_backend);
+
        return -EINVAL;
 }