Skip to content

Commit

Permalink
drm/shmem-helper: Remove another errant put in error path
Browse files Browse the repository at this point in the history
drm_gem_shmem_mmap() doesn't own reference in error code path, resulting
in the dma-buf shmem GEM object getting prematurely freed leading to a
later use-after-free.

Fixes: f49a51b ("drm/shme-helpers: Fix dma_buf_mmap forwarding bug")
Cc: [email protected]
Signed-off-by: Dmitry Osipenko <[email protected]>
Reviewed-by: Rob Clark <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
digetx committed Feb 26, 2023
1 parent a54bace commit ee9adb7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/gpu/drm/drm_gem_shmem_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,14 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct
int ret;

if (obj->import_attach) {
/* Drop the reference drm_gem_mmap_obj() acquired.*/
drm_gem_object_put(obj);
vma->vm_private_data = NULL;
ret = dma_buf_mmap(obj->dma_buf, vma, 0);

/* Drop the reference drm_gem_mmap_obj() acquired.*/
if (!ret)
drm_gem_object_put(obj);

return dma_buf_mmap(obj->dma_buf, vma, 0);
return ret;
}

ret = drm_gem_shmem_get_pages(shmem);
Expand Down

0 comments on commit ee9adb7

Please sign in to comment.