From: Catalin Marinas <catalin.marinas@arm.com>
To: Phil Carmody <ext-phil.2.carmody@nokia.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kmemleak: Never return a pointer you didn't 'get'
Date: Wed, 27 Apr 2011 10:31:20 +0100 [thread overview]
Message-ID: <1303896680.15101.1.camel@e102109-lin.cambridge.arm.com> (raw)
In-Reply-To: <1303385972-2518-1-git-send-email-ext-phil.2.carmody@nokia.com>
On Thu, 2011-04-21 at 12:39 +0100, Phil Carmody wrote:
> 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>
Good catch. But I think the code may look slightly simpler as below:
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index c1d5867..aacee45 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1414,9 +1414,12 @@ static void *kmemleak_seq_next(struct seq_file *seq, void *v, loff_t *pos)
++(*pos);
list_for_each_continue_rcu(n, &object_list) {
- next_obj = list_entry(n, struct kmemleak_object, object_list);
- if (get_object(next_obj))
+ struct kmemleak_object *obj =
+ list_entry(n, struct kmemleak_object, object_list);
+ if (get_object(obj)) {
+ next_obj = obj;
break;
+ }
}
put_object(prev_obj);
Thanks.
--
Catalin
next prev parent reply other threads:[~2011-04-27 9:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 11:39 [PATCH] kmemleak: Never return a pointer you didn't 'get' Phil Carmody
2011-04-27 9:31 ` Catalin Marinas [this message]
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=1303896680.15101.1.camel@e102109-lin.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=ext-phil.2.carmody@nokia.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;
as well as URLs for NNTP newsgroup(s).