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

drm/amdgpu: Use kvfree instead of kfree in amdgpu_gmc_get_nps_memranges()



amdgpu_discovery_get_nps_info() internally allocates memory for ranges
using kvcalloc(), which may use vmalloc() for large allocation. Using
kfree() to release vmalloc memory will lead to a memory corruption.

Use kvfree() to safely handle both kmalloc and vmalloc allocations.

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

Fixes: b194d21b ("drm/amdgpu: Use NPS ranges from discovery table")
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 c9be63d5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1436,7 +1436,7 @@ int amdgpu_gmc_get_nps_memranges(struct amdgpu_device *adev,
	if (!*exp_ranges)
		*exp_ranges = range_cnt;
err:
	kfree(ranges);
	kvfree(ranges);

	return ret;
}