Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1404844 > unrolled thread

[PATCH] dma-buf: use vma_pages().

Started byMuhammad Falak R Wani <falakreyaz@gmail.com>
First post2016-05-21 15:30 +0200
Last post2016-05-23 13:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] dma-buf: use vma_pages(). Muhammad Falak R Wani <falakreyaz@gmail.com> - 2016-05-21 15:30 +0200
    Re: [PATCH] dma-buf: use vma_pages(). Eric Engestrom <eric.engestrom@imgtec.com> - 2016-05-23 13:10 +0200

#1404844 — [PATCH] dma-buf: use vma_pages().

FromMuhammad Falak R Wani <falakreyaz@gmail.com>
Date2016-05-21 15:30 +0200
Subject[PATCH] dma-buf: use vma_pages().
Message-ID<rBf8B-40U-15@gated-at.bofh.it>
Replace explicit computation of vma page count by a call to
vma_pages()

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
---
 drivers/dma-buf/dma-buf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 4a2c07e..b0317ec 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -90,7 +90,7 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
 	dmabuf = file->private_data;
 
 	/* check for overflowing the buffer's size */
-	if (vma->vm_pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) >
+	if (vma->vm_pgoff + vma_pages(vma) >
 	    dmabuf->size >> PAGE_SHIFT)
 		return -EINVAL;
 
@@ -723,11 +723,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
 		return -EINVAL;
 
 	/* check for offset overflow */
-	if (pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) < pgoff)
+	if (pgoff + vma_pages(vma) < pgoff)
 		return -EOVERFLOW;
 
 	/* check for overflowing the buffer's size */
-	if (pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) >
+	if (pgoff + vma_pages(vma) >
 	    dmabuf->size >> PAGE_SHIFT)
 		return -EINVAL;
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1405251

FromEric Engestrom <eric.engestrom@imgtec.com>
Date2016-05-23 13:10 +0200
Message-ID<rBVUd-53H-5@gated-at.bofh.it>
In reply to#1404844
On Sat, May 21, 2016 at 06:53:32PM +0530, Muhammad Falak R Wani wrote:
> Replace explicit computation of vma page count by a call to
> vma_pages()
> 
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
> ---

Good change, but this function is defined in mm.h
Please add:

    #include <linux/mm.h>

With that fixed:
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web