Skip to content
/ linux Public

Commit 18a7bbd

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 3f2d2cb commit 18a7bbd

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
@@ -1132,8 +1132,10 @@ static int amdgpu_acpi_enumerate_xcc(void)
11321132
if (!dev_info)
11331133
ret = amdgpu_acpi_dev_init(&dev_info, xcc_info, sbdf);
11341134

1135-
if (ret == -ENOMEM)
1135+
if (ret == -ENOMEM) {
1136+
kfree(xcc_info);
11361137
return ret;
1138+
}
11371139

11381140
if (!dev_info) {
11391141
kfree(xcc_info);

0 commit comments

Comments
 (0)