]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/amdgpu: fix memory leak when ras is not supported on specific ip block
authorHawking Zhang <Hawking.Zhang@amd.com>
Sat, 31 Aug 2019 06:20:38 +0000 (14:20 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 13 Sep 2019 22:36:22 +0000 (17:36 -0500)
free ras_if if ras is not supported

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c

index 351aefcf31518ffc5756b0fc42f508f2c270616d..1bd2f56186f25b9f5abcf06d0b0242aa5b4904c6 100644 (file)
@@ -4440,7 +4440,8 @@ static int gfx_v9_0_ecc_late_init(void *handle)
                r = amdgpu_irq_get(adev, &adev->gfx.cp_ecc_error_irq, 0);
                if (r)
                        goto late_fini;
-       }
+       } else
+               kfree(adev->gfx.ras_if);
 
        return 0;
 late_fini:
index 08a47a5785cd697cacfeea7c18d1e6878d1bc6fe..6a61e5c5b2cea80dbcfa00523cc36d8707ee3700 100644 (file)
@@ -797,7 +797,8 @@ static int gmc_v9_0_ecc_late_init(void *handle)
                r = amdgpu_irq_get(adev, &adev->gmc.ecc_irq, 0);
                if (r)
                        goto umc_late_fini;
-       }
+       } else
+               kfree(adev->gmc.umc_ras_if);
 
        if (adev->mmhub_funcs && adev->mmhub_funcs->ras_late_init) {
                r = adev->mmhub_funcs->ras_late_init(adev);
index af15f4b8e3ad812b6a23f9f91d5a11b8b2a8fecd..ab6559a2d5e8f22508805236aa46fc19fb211cb3 100644 (file)
@@ -639,7 +639,7 @@ static int mmhub_v1_0_ras_late_init(struct amdgpu_device *adev)
        mmhub_ih_info.head = mmhub_fs_info.head = *adev->gmc.mmhub_ras_if;
        r = amdgpu_ras_late_init(adev, adev->gmc.mmhub_ras_if,
                                 &mmhub_fs_info, &mmhub_ih_info);
-       if (r)
+       if (r || !amdgpu_ras_is_supported(adev, adev->gmc.mmhub_ras_if->block))
                kfree(adev->gmc.mmhub_ras_if);
        return r;
 }
index 82980efd3ee65a34a7829391ad370f7d4bd3eb88..4830382ab8f2df84f6f3b2c67a13c401ea858568 100644 (file)
@@ -1728,7 +1728,8 @@ static int sdma_v4_0_late_init(void *handle)
                        if (r)
                                goto late_fini;
                }
-       }
+       } else
+               kfree(adev->sdma.ras_if);
 
         return 0;
 late_fini: