From: Randy Dunlap <randy.dunlap@oracle.com>
To: Amit Choudhary <amit2030@yahoo.com>
Cc: Valdis.Kletnieks@vt.edu, Pekka Enberg <penberg@cs.helsinki.fi>,
Hua Zhong <hzhong@gmail.com>,
Christoph Hellwig <hch@infradead.org>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] include/linux/slab.h: new KFREE() macro.
Date: Tue, 9 Jan 2007 11:19:55 -0800 [thread overview]
Message-ID: <20070109111955.85496022.randy.dunlap@oracle.com> (raw)
In-Reply-To: <88063.16727.qm@web55602.mail.re4.yahoo.com>
On Tue, 9 Jan 2007 11:02:35 -0800 (PST) Amit Choudhary wrote:
>
> --- Valdis.Kletnieks@vt.edu wrote:
>
> > On Mon, 08 Jan 2007 01:06:12 PST, Amit Choudhary said:
> > > I do not see how a double free can result in _logical_wrong_behaviour_ of the program and the
> > > program keeps on running (like an incoming packet being dropped because of double free).
> > Double
> > > free will _only_and_only_ result in system crash that can be solved by setting 'x' to NULL.
> >
> > The problem is that very rarely is there a second free() with no intervening
> > use - what actually *happens* usually is:
> >
> > 1) You alloc the memory
> > 2) You use the memory
> > 3) You take a reference on the memory, so you know where it is.
> > 4) You free the memory
> > 5) You use the memory via the reference you took in (3)
> > 6) You free it again - at which point you finally know for sure that
> > everything in step 5 was doing a fandango on core....
> >
>
> Correct. And doing kfree(x); x=NULL; is not hiding that. These issues can still be debugged by
> using the slab debugging options. One other benefit of doing this is that if someone tries to
> access the same memory again using the variable 'x', then he will get an immediate crash. And the
> problem can be solved immediately, without using the slab debugging options. I do not yet
> understand how doing this hides the bugs, obfuscates the code, etc. because I haven't seen an
> example yet, but only blanket statements.
>
> But now I know better, since I haven't heard anything in support of this case, I have concluded
> that doing kfree(x); x=NULL; is _not_needed_ in the "linux kernel". I hope that no one does it in
> the future. And since people vehemently opposed this, I think its better to add another item on
> the kernel janitor's list to remove all the (x=NULL) statements where people are doing "kfree(x);
> x=NULL".
No thanks. If a driver author wants to maintain driver state
that way, it's OK, but that doesn't make it a global requirement.
---
~Randy
next prev parent reply other threads:[~2007-01-09 19:21 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-07 8:46 [PATCH] include/linux/slab.h: new KFREE() macro Amit Choudhary
2007-01-07 10:24 ` Christoph Hellwig
2007-01-07 22:43 ` Amit Choudhary
2007-01-07 23:22 ` Vadim Lobanov
2007-01-08 0:02 ` Amit Choudhary
2007-01-08 2:35 ` Vadim Lobanov
2007-01-08 4:09 ` Amit Choudhary
2007-01-08 7:04 ` Vadim Lobanov
2007-01-08 7:29 ` Amit Choudhary
2007-01-08 8:15 ` Vadim Lobanov
2007-01-08 8:47 ` Amit Choudhary
2007-01-08 9:09 ` Al Viro
2007-01-08 7:49 ` Hua Zhong
2007-01-08 8:00 ` Pekka Enberg
2007-01-08 8:31 ` Amit Choudhary
2007-01-08 8:37 ` Al Viro
2007-01-08 8:39 ` Sumit Narayan
2007-01-08 8:44 ` Robert P. J. Day
2007-01-08 8:56 ` Amit Choudhary
2007-01-08 8:45 ` Pekka Enberg
2007-01-08 9:06 ` Amit Choudhary
2007-01-08 9:26 ` Pekka Enberg
2007-01-08 22:43 ` Valdis.Kletnieks
2007-01-09 19:02 ` Amit Choudhary
2007-01-09 19:19 ` Randy Dunlap [this message]
2007-01-10 4:57 ` Amit Choudhary
2007-01-09 22:57 ` Valdis.Kletnieks
2007-01-10 0:00 ` Amit Choudhary
2007-01-10 2:43 ` Valdis.Kletnieks
2007-01-08 11:10 ` Jesper Juhl
2007-01-08 8:05 ` Amit Choudhary
2007-01-08 8:12 ` Al Viro
2007-01-08 8:57 ` Hua Zhong
-- strict thread matches above, loose matches on Subject: below --
2007-07-23 17:55 Amit Choudhary
[not found] <7ADs5-25a-11@gated-at.bofh.it>
[not found] ` <7AP02-3l3-13@gated-at.bofh.it>
2007-01-08 18:29 ` Bodo Eggert
2007-01-01 0:17 Amit Choudhary
2007-01-01 3:01 ` Segher Boessenkool
2007-01-01 21:23 ` Pekka Enberg
2007-01-02 9:21 ` Christoph Hellwig
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=20070109111955.85496022.randy.dunlap@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=amit2030@yahoo.com \
--cc=hch@infradead.org \
--cc=hzhong@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
/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