Skip to contentSkip to conversation

drm/ttm: capture overflow of mapping boundary in ttm_bo_kmap()

PATCH New Hillf Danton 1 participant 1 message Apr 2, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: capture overflow of mapping boundary in ttm_bo_kmap()

Simply complain if the combined result of start_page and num_pages goes over the pages bo has. Let me know if the added warning is too heavy a hammer.

Cc Christian Koenig <[email protected]>
Cc Huang Rui <[email protected]>
Cc Junwei Zhang <[email protected]>

---

drivers/gpu/drm/ttm/ttm_bo_util.c +2 -0
@@ -631,6 +631,8 @@ int ttm_bo_kmap(struct ttm_buffer_object
 		return -EINVAL;
 	if (start_page > bo->num_pages)
 		return -EINVAL;
+	if (WARN_ON(start_page > bo->num_pages - num_pages))
+		return -EINVAL;
 
 	(void) ttm_mem_io_lock(man, false);
 	ret = ttm_mem_io_reserve(bo->bdev, &bo->mem);

--

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel