Enforce the access flags that were added earlier. Signed-off-by: Gurchetan Singh <gurchetansingh@xxxxxxxxxxxx> --- drivers/dma-buf/udmabuf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index 4ecf2a94fed3..134e53d24c2b 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -16,6 +16,7 @@ static const u32 list_limit = 1024; /* udmabuf_create_list->count limit */ static const size_t size_limit_mb = 64; /* total dmabuf size, in megabytes */ struct udmabuf { + u32 flags; pgoff_t pagecount; struct page **pages; }; @@ -37,10 +38,17 @@ static const struct vm_operations_struct udmabuf_vm_ops = { static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma) { struct udmabuf *ubuf = buf->priv; + pgprot_t pgprot = vm_get_page_prot(vma->vm_flags); if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0) return -EINVAL; + if (ubuf->flags & UDMABUF_FLAGS_PROT_NONE) + return -EINVAL; + + if ((ubuf->flags & UDMABUF_FLAGS_PROT_READ) == 0) + vma->vm_page_prot = pgprot_writecombine(pgprot); + vma->vm_ops = &udmabuf_vm_ops; vma->vm_private_data = ubuf; return 0; @@ -193,6 +201,7 @@ static long udmabuf_create(const struct udmabuf_create_list *head, else if (head->flags & UDMABUF_FLAGS_PROT_WRITE) exp_info.flags = O_WRONLY; + ubuf->flags = head->flags; buf = dma_buf_export(&exp_info); if (IS_ERR(buf)) { ret = PTR_ERR(buf); -- 2.17.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel