From: Catalin Marinas <catalin.marinas@arm.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] kmemleak: Report previously found leaks even after an error
Date: Thu, 29 Sep 2011 12:02:39 +0100 [thread overview]
Message-ID: <20110929110239.10660.95998.stgit@e102109-lin.cambridge.arm.com> (raw)
In-Reply-To: <20110929105940.10660.76130.stgit@e102109-lin.cambridge.arm.com>
If an error fatal to kmemleak (like memory allocation failure) happens,
kmemleak disables itself but it also removes the access to any
previously found memory leaks. This patch allows read-only access to the
kmemleak debugfs interface but disables any other action.
Repored-by: Nick Bowler <nbowler@elliptictech.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
mm/kmemleak.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index e6dd17b..381b67a 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1473,9 +1473,6 @@ static const struct seq_operations kmemleak_seq_ops = {
static int kmemleak_open(struct inode *inode, struct file *file)
{
- if (!atomic_read(&kmemleak_enabled))
- return -EBUSY;
-
return seq_open(file, &kmemleak_seq_ops);
}
@@ -1549,6 +1546,9 @@ static ssize_t kmemleak_write(struct file *file, const char __user *user_buf,
int buf_size;
int ret;
+ if (!atomic_read(&kmemleak_enabled))
+ return -EBUSY;
+
buf_size = min(size, (sizeof(buf) - 1));
if (strncpy_from_user(buf, user_buf, buf_size) < 0)
return -EFAULT;
@@ -1608,20 +1608,24 @@ static const struct file_operations kmemleak_fops = {
};
/*
- * Perform the freeing of the kmemleak internal objects after waiting for any
- * current memory scan to complete.
+ * Stop the memory scanning thread and free the kmemleak internal objects if
+ * no previous scan thread (otherwise, kmemleak may still have some useful
+ * information on memory leaks).
*/
static void kmemleak_do_cleanup(struct work_struct *work)
{
struct kmemleak_object *object;
+ bool cleanup = scan_thread == NULL;
mutex_lock(&scan_mutex);
stop_scan_thread();
- rcu_read_lock();
- list_for_each_entry_rcu(object, &object_list, object_list)
- delete_object_full(object->pointer);
- rcu_read_unlock();
+ if (cleanup) {
+ rcu_read_lock();
+ list_for_each_entry_rcu(object, &object_list, object_list)
+ delete_object_full(object->pointer);
+ rcu_read_unlock();
+ }
mutex_unlock(&scan_mutex);
}
next prev parent reply other threads:[~2011-09-29 11:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-29 11:02 [PATCH 0/4] Kmemleak patches for -next Catalin Marinas
2011-09-29 11:02 ` [PATCH 1/4] kmemleak: Show where early_log issues come from Catalin Marinas
2011-09-29 11:02 ` [PATCH 2/4] kmemleak: Handle percpu memory allocation Catalin Marinas
2011-09-29 11:56 ` Eric Dumazet
2011-09-29 17:17 ` Catalin Marinas
2011-09-29 17:57 ` Christoph Lameter
2011-09-29 19:28 ` Tejun Heo
2011-09-30 8:37 ` Catalin Marinas
2011-10-03 15:21 ` Catalin Marinas
2011-10-03 16:14 ` Christoph Lameter
2011-10-04 7:59 ` Tejun Heo
2011-10-04 9:04 ` Catalin Marinas
2011-10-04 9:13 ` Tejun Heo
2011-10-04 9:26 ` Catalin Marinas
2011-10-04 16:59 ` Tejun Heo
2011-10-04 17:06 ` Catalin Marinas
2011-09-29 11:02 ` [PATCH 3/4] kmemleak: When the early log buffer is exceeded, report the actual number Catalin Marinas
2011-09-29 11:02 ` Catalin Marinas [this message]
2011-10-04 17:45 ` [PATCH 4/4] kmemleak: Report previously found leaks even after an error Nick Bowler
2011-10-04 20:50 ` Catalin Marinas
2011-10-04 21:14 ` Nick Bowler
2011-10-24 18:57 ` Nick Bowler
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=20110929110239.10660.95998.stgit@e102109-lin.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®