]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/gpusvm: free the whole IOVA reservation on unmap
authorHonglei Huang <honghuan@amd.com>
Wed, 1 Jul 2026 06:27:58 +0000 (14:27 +0800)
committerMatthew Brost <matthew.brost@intel.com>
Tue, 14 Jul 2026 16:27:30 +0000 (09:27 -0700)
commit0bc7c196f3ab855da0879283ba633c4c51ddfd81
tree09442977a2341569dc893f473575bab3c633277c
parentd1b894c5bbb3fee0012bd14356286dc2384e8213
drm/gpusvm: free the whole IOVA reservation on unmap

dma_iova_try_alloc() reserves IOVA for the entire range, but in a mixed
range only the system pages are linked (their total size is state_offset)
while device pages never touch the IOVA state. dma_iova_destroy() with
state_offset only frees the linked part, permanently leaking the IOVA
reserved for the device pages and eventually exhausting the IOVA space.

Unlink the linked system-page portion and free the whole reserved IOVA
instead. On the get_pages() error path state_offset is 0 (no page linked,
dma_addr[0] unpopulated), so skip the unlink and just free the reservation;
this also avoids reading the uninitialized dma_addr[0].dir there.

Allocate the dma_addr array with the zeroing kvzalloc_objs() so every entry
has a well-defined value.

This issue was found by Sashiko AI review.

Fixes: 37ad039fb367 ("drm/gpusvm: Use dma-map IOVA alloc, link, and sync API in GPU SVM")
Cc: stable@vger.kernel.org
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Honglei Huang <honghuan@amd.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260701062800.409248-2-honghuan@amd.com
drivers/gpu/drm/drm_gpusvm.c