From: <rcampbell@nvidia.com>
To: <linux-mm@kvack.org>
Cc: "Ralph Campbell" <rcampbell@nvidia.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Jérôme Glisse" <jglisse@redhat.com>,
"John Hubbard" <jhubbard@nvidia.com>
Subject: [PATCH] mm/hmm: Fix struct hmm memory leak
Date: Fri, 15 Feb 2019 13:59:22 -0800 [thread overview]
Message-ID: <20190215215922.29797-1-rcampbell@nvidia.com> (raw)
From: Ralph Campbell <rcampbell@nvidia.com>
The patch [1] introduced reference counting on struct hmm and works
fine when calling hmm_mirror_register() and hmm_mirror_unregister().
However, when a process exits without explicitly unregistering,
the MMU notifier callback hmm_release() doesn't release the mirror->hmm
reference and thus leaks the struct hmm allocation.
Fix this by releasing the reference in hmm_release().
[1] https://marc.info/?l=linux-mm&m=154878089214597&w=2
("mm/hmm: use reference counting for HMM struct")
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: John Hubbard <jhubbard@nvidia.com>
---
mm/hmm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/hmm.c b/mm/hmm.c
index 3c9781037918..50523df6ea0c 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -179,6 +179,8 @@ static void hmm_release(struct mmu_notifier *mn, struct mm_struct *mm)
mirror->ops->release(mirror);
down_write(&hmm->mirrors_sem);
}
+ hmm_put(mirror->hmm);
+ mirror->hmm = NULL;
mirror = list_first_entry_or_null(&hmm->mirrors,
struct hmm_mirror, list);
}
--
2.17.2
next reply other threads:[~2019-02-15 21:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-15 21:59 rcampbell [this message]
2019-02-16 3:25 ` Jerome Glisse
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=20190215215922.29797-1-rcampbell@nvidia.com \
--to=rcampbell@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=linux-mm@kvack.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