Skip to content

Commit fb4ef4a

Browse files
author
Thomas Zimmermann
committed
Revert "drm/prime: Use dma_buf from GEM object instance"
This reverts commit f83a9b8. 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. v3: - cc stable 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]> Cc: <[email protected]> # v6.15+ Link: https://lore.kernel.org/r/[email protected]
1 parent bb7f497 commit fb4ef4a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/gpu/drm/drm_prime.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,13 @@ struct dma_buf *drm_gem_prime_handle_to_dmabuf(struct drm_device *dev,
453453
}
454454

455455
mutex_lock(&dev->object_name_lock);
456-
/* re-export the original imported/exported object */
456+
/* re-export the original imported object */
457+
if (obj->import_attach) {
458+
dmabuf = obj->import_attach->dmabuf;
459+
get_dma_buf(dmabuf);
460+
goto out_have_obj;
461+
}
462+
457463
if (obj->dma_buf) {
458464
get_dma_buf(obj->dma_buf);
459465
dmabuf = obj->dma_buf;

0 commit comments

Comments
 (0)