[PATCH] drm/vkms: off by one in vkms_gem_fault()

Dan Carpenter dan.carpenter at oracle.com
Sat Jul 14 11:04:13 UTC 2018


The > should be >= so that we don't read one page beyond the end of the
obj->pages[] array.

Fixes: 559e50fd34d1 ("drm/vkms: Add dumb operations")
Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>

diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c
index c7e38368602b..2cca8c2f260f 100644
--- a/drivers/gpu/drm/vkms/vkms_gem.c
+++ b/drivers/gpu/drm/vkms/vkms_gem.c
@@ -55,7 +55,7 @@ int vkms_gem_fault(struct vm_fault *vmf)
 	page_offset = (vaddr - vma->vm_start) >> PAGE_SHIFT;
 	num_pages = DIV_ROUND_UP(obj->gem.size, PAGE_SIZE);
 
-	if (page_offset > num_pages)
+	if (page_offset >= num_pages)
 		return VM_FAULT_SIGBUS;
 
 	ret = -ENOENT;


More information about the dri-devel mailing list