diff options
author | Nirmoy Das <[email protected]> | 2023-01-17 18:52:36 +0100 |
---|---|---|
committer | Maxime Ripard <[email protected]> | 2023-01-19 14:17:05 +0100 |
commit | 0220e4fe178c3390eb0291cdb34912d66972db8a (patch) | |
tree | 0fd93a9cab3339b23e4e723f2fe12f5e216da5ca | |
parent | 899d3a3c19ac0e5da013ce34833dccb97d19b5e4 (diff) |
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: 786555987207 ("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]>
-rw-r--r-- | drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c index 0ad44f3868de..c7c252d4d366 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c @@ -697,7 +697,7 @@ insert: GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo); out: if (file) - drm_vma_node_allow(&mmo->vma_node, file); + drm_vma_node_allow_once(&mmo->vma_node, file); return mmo; err: |