Skip to content

Commit 07dd476

Browse files
committed
drm/shmem-helper: Reset vma->vm_ops before calling dma_buf_mmap()
The dma-buf backend is supposed to provide its own vm_ops, but some implementation just have nothing special to do and leave vm_ops untouched, probably expecting this field to be zero initialized (this is the case with the system_heap implementation for instance). Let's reset vma->vm_ops to NULL to keep things working with these implementations. Fixes: 26d3ac3 ("drm/shmem-helpers: Redirect mmap for imported dma-buf") Cc: <stable@vger.kernel.org> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Reported-by: Roman Stratiienko <r.stratiienko@gmail.com> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Tested-by: Roman Stratiienko <r.stratiienko@gmail.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patchwork.freedesktop.org/patch/msgid/20230724112610.60974-1-boris.brezillon@collabora.com
1 parent 43dae31 commit 07dd476

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/gpu/drm/drm_gem_shmem_helper.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,13 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct
623623
int ret;
624624

625625
if (obj->import_attach) {
626+
/* Reset both vm_ops and vm_private_data, so we don't end up with
627+
* vm_ops pointing to our implementation if the dma-buf backend
628+
* doesn't set those fields.
629+
*/
626630
vma->vm_private_data = NULL;
631+
vma->vm_ops = NULL;
632+
627633
ret = dma_buf_mmap(obj->dma_buf, vma, 0);
628634

629635
/* Drop the reference drm_gem_mmap_obj() acquired.*/

0 commit comments

Comments
 (0)