Skip to content
/ linux Public

Commit e87c73a

Browse files
GoodLuck612Sasha Levin
authored andcommitted
drm/amdgpu: Fix memory leak in amdgpu_acpi_enumerate_xcc()
[ Upstream commit c9be63d ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8dc6bec commit e87c73a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,10 @@ static int amdgpu_acpi_enumerate_xcc(void)
11281128
if (!dev_info)
11291129
ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, bdf);
11301130

1131-
if (ret == -ENOMEM)
1131+
if (ret == -ENOMEM) {
1132+
kfree(xcc_info);
11321133
return ret;
1134+
}
11331135

11341136
if (!dev_info) {
11351137
kfree(xcc_info);

0 commit comments

Comments
 (0)