From: Nirmoy Das <nirmoy.das@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org, Nirmoy Das <nirmoy.das@intel.com>
Subject: [Intel-gfx] [PATCH 2/2] drm/i915: Fix a memory leak with reused mmap_offset
Date: Tue, 17 Jan 2023 18:52:36 +0100 [thread overview]
Message-ID: <20230117175236.22317-2-nirmoy.das@intel.com> (raw)
In-Reply-To: <20230117175236.22317-1-nirmoy.das@intel.com>
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>
---
drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index 4f69bff63068..2aac6bf78740 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 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
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:
--
2.39.0
next prev parent reply other threads:[~2023-01-17 17:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 17:52 [Intel-gfx] [PATCH 1/2] drm/drm_vma_manager: Add drm_vma_node_allow_once() Nirmoy Das
2023-01-17 17:52 ` Nirmoy Das [this message]
2023-01-18 9:19 ` [Intel-gfx] [PATCH 2/2] drm/i915: Fix a memory leak with reused mmap_offset Tvrtko Ursulin
2023-01-18 9:27 ` Das, Nirmoy
2023-01-18 9:40 ` Andi Shyti
2023-01-18 10:26 ` Mirsad Todorovac
2023-01-18 10:39 ` Das, Nirmoy
2023-01-18 10:53 ` Mirsad Todorovac
2023-01-18 22:27 ` Mirsad Goran Todorovac
2023-01-17 21:56 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/2] drm/drm_vma_manager: Add drm_vma_node_allow_once() Patchwork
2023-01-18 9:22 ` [Intel-gfx] [PATCH 1/2] " Tvrtko Ursulin
2023-01-18 9:38 ` Andi Shyti
2023-01-18 9:45 ` Das, Nirmoy
2023-01-18 11:07 ` [Intel-gfx] ✓ Fi.CI.IGT: success for series starting with [1/2] " Patchwork
2023-01-18 13:19 ` [Intel-gfx] [PATCH 1/2] " Tvrtko Ursulin
2023-01-18 13:34 ` Tvrtko Ursulin
2023-01-19 13:25 ` Maxime Ripard
2023-01-19 13:27 ` Das, Nirmoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230117175236.22317-2-nirmoy.das@intel.com \
--to=nirmoy.das@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox