Skip to content

Commit d078fd9

Browse files
committed
dma-buf: Move dma_buf_mmap() to dynamic locking specification
Move dma_buf_mmap() function to the dynamic locking specification by taking the reservation lock. Neither of the today's drivers take the reservation lock within the mmap() callback, hence it's safe to enforce the locking. Acked-by: Sumit Semwal <[email protected]> Acked-by: Christian König <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 47e982d commit d078fd9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/dma-buf/dma-buf.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,8 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_end_cpu_access, DMA_BUF);
13901390
int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
13911391
unsigned long pgoff)
13921392
{
1393+
int ret;
1394+
13931395
if (WARN_ON(!dmabuf || !vma))
13941396
return -EINVAL;
13951397

@@ -1410,7 +1412,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
14101412
vma_set_file(vma, dmabuf->file);
14111413
vma->vm_pgoff = pgoff;
14121414

1413-
return dmabuf->ops->mmap(dmabuf, vma);
1415+
dma_resv_lock(dmabuf->resv, NULL);
1416+
ret = dmabuf->ops->mmap(dmabuf, vma);
1417+
dma_resv_unlock(dmabuf->resv);
1418+
1419+
return ret;
14141420
}
14151421
EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, DMA_BUF);
14161422

0 commit comments

Comments
 (0)