diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2019-03-22 09:41:25 +0300 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2019-04-01 10:44:34 -0700 |
commit | 3a3fe6e766630aacf8cc212cceb1d57d7b346463 (patch) | |
tree | 7d2c934ec39fc4d8ea86b7feb470af71b429374b /drivers | |
parent | 3051719af11eb48dc8947826cfb66dbe0f281c7d (diff) | |
download | linux-3a3fe6e766630aacf8cc212cceb1d57d7b346463.tar.bz2 |
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: 2194a63a818d ("drm: Add library for shmem backed GEM objects")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20190322064125.GA12551@kadam
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/drm_gem_shmem_helper.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 3750a982aaf6..1ee208c2c85e 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -408,7 +408,7 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) loff_t num_pages = obj->size >> PAGE_SHIFT; struct page *page; - if (vmf->pgoff > num_pages || WARN_ON_ONCE(!shmem->pages)) + if (vmf->pgoff >= num_pages || WARN_ON_ONCE(!shmem->pages)) return VM_FAULT_SIGBUS; page = shmem->pages[vmf->pgoff]; |