]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915: Fix a memory leak with reused mmap_offset
authorNirmoy Das <nirmoy.das@intel.com>
Tue, 17 Jan 2023 17:52:36 +0000 (18:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:34:42 +0000 (08:34 +0100)
commite081a993c23affa0772d7882d7b9d77c6913c123
treea6e7fdc4c8d29b86ce0555eadab7c7447f0b184e
parent2901646096359fb64fad5eb5f4dd2ebea4ed7107
drm/i915: Fix a memory leak with reused mmap_offset

[ Upstream commit 8ba953d103ad70c9a040350864b9c8dad43f72f5 ]

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 <tvrtko.ursulin@linux.intel.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
Fixes: 1b37b55a438c ("drm/i915/gem: Store mmap_offsets in an rbtree rather than a plain list")
Reported-by: Chuansheng Liu <chuansheng.liu@intel.com>
Reported-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/20230117175236.22317-2-nirmoy.das@intel.com
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/i915/gem/i915_gem_mman.c