UPSTREAM: dma-buf: Make mmap callback actually optional
The docs state the callback is optional but it is not, make it optional. Signed-off-by: Andrew F. Davis <afd@ti.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20190329165201.16233-1-afd@ti.com (cherry picked from commit e3a9d6c53195591303b7f165f3bb0226741f911e) Change-Id: I418159f4b0cba42ee77a7916d620eb97229ff38d Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
This commit is contained in:
committed by
Tao Huang
parent
4c5adce2d2
commit
ef53e337ca
@ -173,6 +173,10 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
|
||||
|
||||
dmabuf = file->private_data;
|
||||
|
||||
/* check if buffer supports mmap */
|
||||
if (!dmabuf->ops->mmap)
|
||||
return -EINVAL;
|
||||
|
||||
/* check for overflowing the buffer's size */
|
||||
if (vma->vm_pgoff + vma_pages(vma) >
|
||||
dmabuf->size >> PAGE_SHIFT)
|
||||
@ -672,8 +676,7 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
|
||||
|| !exp_info->ops
|
||||
|| !exp_info->ops->map_dma_buf
|
||||
|| !exp_info->ops->unmap_dma_buf
|
||||
|| !exp_info->ops->release
|
||||
|| !exp_info->ops->mmap)) {
|
||||
|| !exp_info->ops->release)) {
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
@ -1256,6 +1259,10 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
|
||||
if (WARN_ON(!dmabuf || !vma))
|
||||
return -EINVAL;
|
||||
|
||||
/* check if buffer supports mmap */
|
||||
if (!dmabuf->ops->mmap)
|
||||
return -EINVAL;
|
||||
|
||||
/* check for offset overflow */
|
||||
if (pgoff + vma_pages(vma) < pgoff)
|
||||
return -EOVERFLOW;
|
||||
|
||||
Reference in New Issue
Block a user