Skip to content

Commit 1e9d2ae

Browse files
author
Thomas Zimmermann
committed
Revert "drm/vmwgfx: Use dma_buf from GEM object instance"
This reverts commit aec8a40. 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 0ecfb8d commit 1e9d2ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_gem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ static int vmw_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
8585
int ret;
8686

8787
if (drm_gem_is_imported(obj)) {
88-
ret = dma_buf_vmap(obj->dma_buf, map);
88+
ret = dma_buf_vmap(obj->import_attach->dmabuf, map);
8989
if (!ret) {
9090
if (drm_WARN_ON(obj->dev, map->is_iomem)) {
91-
dma_buf_vunmap(obj->dma_buf, map);
91+
dma_buf_vunmap(obj->import_attach->dmabuf, map);
9292
return -EIO;
9393
}
9494
}
@@ -102,7 +102,7 @@ static int vmw_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
102102
static void vmw_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map)
103103
{
104104
if (drm_gem_is_imported(obj))
105-
dma_buf_vunmap(obj->dma_buf, map);
105+
dma_buf_vunmap(obj->import_attach->dmabuf, map);
106106
else
107107
drm_gem_ttm_vunmap(obj, map);
108108
}

0 commit comments

Comments
 (0)