From: Phil Carmody <ext-phil.2.carmody@nokia.com>
To: ext Catalin Marinas <catalin.marinas@arm.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 13:11:30 +0300 [thread overview]
Message-ID: <20110427101129.GA5763@esdhcp04044.research.nokia.com> (raw)
In-Reply-To: <1303896680.15101.1.camel@e102109-lin.cambridge.arm.com>
On 27/04/11 10:31 +0100, ext Catalin Marinas wrote:
> 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);
I did consider that way too, but had no strong preference. I think I now
prefer yours, so please add:
Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Cheers,
Phil
--
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>
prev parent reply other threads:[~2011-04-27 10:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 11:39 Phil Carmody
2011-04-27 9:31 ` Catalin Marinas
2011-04-27 10:11 ` Phil Carmody [this message]
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=20110427101129.GA5763@esdhcp04044.research.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