]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: Fix memory leak in amdgpu_acpi_enumerate_xcc()
authorZilin Guan <zilin@seu.edu.cn>
Thu, 29 Jan 2026 09:25:32 +0000 (09:25 +0000)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 5 Feb 2026 22:17:57 +0000 (17:17 -0500)
In amdgpu_acpi_enumerate_xcc(), if amdgpu_acpi_dev_init() returns -ENOMEM,
the function returns directly without releasing the allocated xcc_info,
resulting in a memory leak.

Fix this by ensuring that xcc_info is properly freed in the error paths.

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

Fixes: 4d5275ab0b18 ("drm/amdgpu: Add parsing of acpi xcc objects")
Reviewed-by: Lijo Lazar <lijo.lazar@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_acpi.c

index c126d1bf2bc83654e7f1d1de5b6a88c70a2bd9c1..02d5abf9df2bae2d948e081b4fae9867d229d7bd 100644 (file)
@@ -1186,8 +1186,10 @@ int amdgpu_acpi_enumerate_xcc(void)
                if (!dev_info)
                        ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, sbdf);
 
-               if (ret == -ENOMEM)
+               if (ret == -ENOMEM) {
+                       kfree(xcc_info);
                        return ret;
+               }
 
                if (!dev_info) {
                        kfree(xcc_info);