Skip to content

Commit c9be63d

Browse files
GoodLuck612alexdeucher
authored andcommitted
drm/amdgpu: Fix memory leak in amdgpu_acpi_enumerate_xcc()
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: 4d5275a ("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>
1 parent c40c946 commit c9be63d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,8 +1186,10 @@ int amdgpu_acpi_enumerate_xcc(void)
11861186
if (!dev_info)
11871187
ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, sbdf);
11881188

1189-
if (ret == -ENOMEM)
1189+
if (ret == -ENOMEM) {
1190+
kfree(xcc_info);
11901191
return ret;
1192+
}
11911193

11921194
if (!dev_info) {
11931195
kfree(xcc_info);

0 commit comments

Comments
 (0)