Commit c9be63d5 authored by Zilin Guan's avatar Zilin Guan Committed by Alex Deucher
Browse files

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: 4d5275ab ("drm/amdgpu: Add parsing of acpi xcc objects")
Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarZilin Guan <zilin@seu.edu.cn>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c40c9469
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);