Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: null check for hmm_pfns ptr before freeing it

Due to low memory or when num of pages is too big to be
accomodated, allocation could fail for pfn's.

Chekc hmm_pfns for NULL before calling the kvfree for the it.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Acked-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Sunil Khatri and committed by
Alex Deucher
84564d29 6f1ee58a

+3 -1
+3 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c
··· 286 286 if (!range) 287 287 return; 288 288 289 - kvfree(range->hmm_range.hmm_pfns); 289 + if (range->hmm_range.hmm_pfns) 290 + kvfree(range->hmm_range.hmm_pfns); 291 + 290 292 amdgpu_bo_unref(&range->bo); 291 293 kfree(range); 292 294 }