Skip to content

Commit bb7f497

Browse files
author
Thomas Zimmermann
committed
Revert "drm/etnaviv: Use dma_buf from GEM object instance"
This reverts commit e91eb3a. The dma_buf field in struct drm_gem_object is not stable over the object instance's lifetime. The field becomes NULL when user space releases the final GEM handle on the buffer object. This resulted in a NULL-pointer deref. Workarounds in commit 5307dce ("drm/gem: Acquire references on GEM handles for framebuffers") and commit f6bfc9a ("drm/framebuffer: Acquire internal references on GEM handles") only solved the problem partially. They especially don't work for buffer objects without a DRM framebuffer associated. Hence, this revert to going back to using .import_attach->dmabuf. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Simona Vetter <[email protected]> Acked-by: Christian König <[email protected]> Acked-by: Zack Rusin <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1e9d2ae commit bb7f497

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)
6565
struct iosys_map map = IOSYS_MAP_INIT_VADDR(etnaviv_obj->vaddr);
6666

6767
if (etnaviv_obj->vaddr)
68-
dma_buf_vunmap_unlocked(etnaviv_obj->base.dma_buf, &map);
68+
dma_buf_vunmap_unlocked(etnaviv_obj->base.import_attach->dmabuf, &map);
6969

7070
/* Don't drop the pages for imported dmabuf, as they are not
7171
* ours, just free the array we allocated:
@@ -82,7 +82,7 @@ static void *etnaviv_gem_prime_vmap_impl(struct etnaviv_gem_object *etnaviv_obj)
8282

8383
lockdep_assert_held(&etnaviv_obj->lock);
8484

85-
ret = dma_buf_vmap(etnaviv_obj->base.dma_buf, &map);
85+
ret = dma_buf_vmap(etnaviv_obj->base.import_attach->dmabuf, &map);
8686
if (ret)
8787
return NULL;
8888
return map.vaddr;

0 commit comments

Comments
 (0)