Skip to content

Commit 0220e4f

Browse files
nirmoymripard
authored andcommitted
drm/i915: Fix a memory leak with reused mmap_offset
drm_vma_node_allow() and drm_vma_node_revoke() should be called in balanced pairs. We call drm_vma_node_allow() once per-file everytime a user calls mmap_offset, but only call drm_vma_node_revoke once per-file on each mmap_offset. As the mmap_offset is reused by the client, the per-file vm_count may remain non-zero and the rbtree leaked. Call drm_vma_node_allow_once() instead to prevent that memory leak. Cc: Tvrtko Ursulin <[email protected]> Cc: Andi Shyti <[email protected]> Signed-off-by: Nirmoy Das <[email protected]> Fixes: 7865559 ("drm/i915/gem: Store mmap_offsets in an rbtree rather than a plain list") Reported-by: Chuansheng Liu <[email protected]> Reported-by: Mirsad Todorovac <[email protected]> Reviewed-by: Tvrtko Ursulin <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Maxime Ripard <[email protected]>
1 parent 899d3a3 commit 0220e4f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/i915/gem/i915_gem_mman.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
697697
GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
698698
out:
699699
if (file)
700-
drm_vma_node_allow(&mmo->vma_node, file);
700+
drm_vma_node_allow_once(&mmo->vma_node, file);
701701
return mmo;
702702

703703
err:

0 commit comments

Comments
 (0)