From: Phil Carmody <ext-phil.2.carmody@nokia.com>
To: catalin.marinas@arm.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
ext-phil.2.carmody@nokia.com
Subject: [PATCH] kmemleak: Never return a pointer you didn't 'get'
Date: Thu, 21 Apr 2011 14:39:32 +0300 [thread overview]
Message-ID: <1303385972-2518-1-git-send-email-ext-phil.2.carmody@nokia.com> (raw)
Old - If you don't get the last pointer that you looked at, then it will
still be put, as there's no way of knowing you didn't get it.
New - If you didn't get it, then it refers to something deleted, and
your work is done, so return NULL.
Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
---
mm/kmemleak.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 8bf765c..3bf204d 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1350,17 +1350,21 @@ static void *kmemleak_seq_next(struct seq_file *seq, void *v, loff_t *pos)
struct kmemleak_object *prev_obj = v;
struct kmemleak_object *next_obj = NULL;
struct list_head *n = &prev_obj->object_list;
+ int found = 0;
++(*pos);
list_for_each_continue_rcu(n, &object_list) {
next_obj = list_entry(n, struct kmemleak_object, object_list);
- if (get_object(next_obj))
+ if (get_object(next_obj)) {
+ found = 1;
break;
+ }
}
put_object(prev_obj);
- return next_obj;
+
+ return found ? next_obj : NULL;
}
/*
--
1.7.2.rc1.37.gf8c40
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2011-04-21 11:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 11:39 Phil Carmody [this message]
2011-04-27 9:31 ` Catalin Marinas
2011-04-27 10:11 ` Phil Carmody
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=1303385972-2518-1-git-send-email-ext-phil.2.carmody@nokia.com \
--to=ext-phil.2.carmody@nokia.com \
--cc=catalin.marinas@arm.com \
--cc=linux-kernel@vger.kernel.org \
--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