Skip to content

Commit 3a3fe6e

Browse files
Dan Carpenteranholt
authored andcommitted
drm: shmem: Off by one in drm_gem_shmem_fault()
The shmem->pages[] array has "num_pages" elements so the > should be >= to prevent reading beyond the end of the array. The shmem->pages[] array is allocated in drm_gem_shmem_prime_import_sg_table(). Fixes: 2194a63 ("drm: Add library for shmem backed GEM objects") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20190322064125.GA12551@kadam
1 parent 3051719 commit 3a3fe6e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/drm_gem_shmem_helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf)
408408
loff_t num_pages = obj->size >> PAGE_SHIFT;
409409
struct page *page;
410410

411-
if (vmf->pgoff > num_pages || WARN_ON_ONCE(!shmem->pages))
411+
if (vmf->pgoff >= num_pages || WARN_ON_ONCE(!shmem->pages))
412412
return VM_FAULT_SIGBUS;
413413

414414
page = shmem->pages[vmf->pgoff];

0 commit comments

Comments
 (0)