Skip to content

Commit b02da6f

Browse files
mfrwsumitsemwal
authored andcommitted
dma-buf: use vma_pages()
Replace explicit computation of vma page count by a call to vma_pages(). Also, include <linux/mm.h> Signed-off-by: Muhammad Falak R Wani <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Signed-off-by: Sumit Semwal <[email protected]>
1 parent 4320c2a commit b02da6f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/dma-buf/dma-buf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/seq_file.h>
3434
#include <linux/poll.h>
3535
#include <linux/reservation.h>
36+
#include <linux/mm.h>
3637

3738
#include <uapi/linux/dma-buf.h>
3839

@@ -90,7 +91,7 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
9091
dmabuf = file->private_data;
9192

9293
/* check for overflowing the buffer's size */
93-
if (vma->vm_pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) >
94+
if (vma->vm_pgoff + vma_pages(vma) >
9495
dmabuf->size >> PAGE_SHIFT)
9596
return -EINVAL;
9697

@@ -723,11 +724,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
723724
return -EINVAL;
724725

725726
/* check for offset overflow */
726-
if (pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) < pgoff)
727+
if (pgoff + vma_pages(vma) < pgoff)
727728
return -EOVERFLOW;
728729

729730
/* check for overflowing the buffer's size */
730-
if (pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) >
731+
if (pgoff + vma_pages(vma) >
731732
dmabuf->size >> PAGE_SHIFT)
732733
return -EINVAL;
733734

0 commit comments

Comments
 (0)