diff mbox series

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

Message ID 20190402074352.AC99E6E6EF@gabe.freedesktop.org (mailing list archive)
State New, archived
Headers show
Series drm/ttm: capture overflow of mapping boundary in ttm_bo_kmap() | expand

Commit Message

Hillf Danton April 2, 2019, 2:21 a.m. UTC
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 <christian.koenig@amd.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Junwei Zhang <Jerry.Zhang@amd.com>
Signed-off-by: Hillf Danton <hdanton@sina.com>
---

--
diff mbox series

Patch

--- a/drivers/gpu/drm/ttm/ttm_bo_util.c	2019-04-02 09:27:24.521761100 +0800
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c	2019-04-02 09:37:52.108898500 +0800
@@ -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);