diff options
author | Dmitry Osipenko <dmitry.osipenko@collabora.com> | 2022-11-10 23:13:48 +0300 |
---|---|---|
committer | Dmitry Osipenko <dmitry.osipenko@collabora.com> | 2022-11-11 23:49:53 +0300 |
commit | 3a6ca1810f774ceed129683d8f8c9721c03512b0 (patch) | |
tree | ba266809e4f8624be158c7ad75e02d9b133de903 /drivers/media/common/videobuf2/videobuf2-vmalloc.c | |
parent | 27f3733a104950169797407fea330a2e1d42f16b (diff) | |
download | linux-3a6ca1810f774ceed129683d8f8c9721c03512b0.tar.xz |
media: videobuf2: Assert held reservation lock for dma-buf mmapping
When userspace mmaps dma-buf's fd, the dma-buf reservation lock must be
held. Add locking sanity checks to the dma-buf mmaping callbacks to ensure
that the locking assumptions won't regress in the future.
Suggested-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221110201349.351294-6-dmitry.osipenko@collabora.com
Diffstat (limited to 'drivers/media/common/videobuf2/videobuf2-vmalloc.c')
-rw-r--r-- | drivers/media/common/videobuf2/videobuf2-vmalloc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c index 41db707e43a4..f9b665366365 100644 --- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c +++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c @@ -10,6 +10,7 @@ * the Free Software Foundation. */ +#include <linux/dma-resv.h> #include <linux/io.h> #include <linux/module.h> #include <linux/mm.h> @@ -316,6 +317,8 @@ static int vb2_vmalloc_dmabuf_ops_vmap(struct dma_buf *dbuf, static int vb2_vmalloc_dmabuf_ops_mmap(struct dma_buf *dbuf, struct vm_area_struct *vma) { + dma_resv_assert_held(dbuf->resv); + return vb2_vmalloc_mmap(dbuf->priv, vma); } |