]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: Fix memory leak in amdgpu_ras_init()
authorZilin Guan <zilin@seu.edu.cn>
Thu, 29 Jan 2026 08:35:15 +0000 (08:35 +0000)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 5 Feb 2026 22:19:09 +0000 (17:19 -0500)
When amdgpu_nbio_ras_sw_init() fails in amdgpu_ras_init(), the function
returns directly without freeing the allocated con structure, leading
to a memory leak.

Fix this by jumping to the release_con label to properly clean up the
allocated memory before returning the error code.

Compile tested only. Issue found using a prototype static analysis tool
and code review.

Fixes: fdc94d3a8c88 ("drm/amdgpu: Rework pcie_bif ras sw_init")
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c

index f582113d78b74c9e8773c25798f79a1ae7d98e70..b28fcf932f7ea250ac4635c44a5a55f19476991a 100644 (file)
@@ -4352,7 +4352,7 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
         * to handle fatal error */
        r = amdgpu_nbio_ras_sw_init(adev);
        if (r)
-               return r;
+               goto release_con;
 
        if (adev->nbio.ras &&
            adev->nbio.ras->init_ras_controller_interrupt) {