Re: 9pfs double kfree

From: Kai Makisara
Date: Mon Mar 06 2006 - 03:34:56 EST


On Mon, 6 Mar 2006, Al Viro wrote:

> On Mon, Mar 06, 2006 at 09:56:22AM +0200, Pekka Enberg wrote:
> > On 3/6/06, Dave Jones <davej@xxxxxxxxxx> wrote:
> > > I wonder if we could get away with something as simple as..
> > >
> > > #define kfree(foo) \
> > > __kfree(foo); \
> > > foo = KFREE_POISON;
> > >
> > > ?
> >
> > It's legal to call kfree() twice for NULL pointer. The above poisons
> > foo unconditionally which makes that case break I think.
>
> Legal, but rather bad taste. Init to NULL, possibly assign the value
> if kmalloc(), then kfree() unconditionally - sure, but that... almost
> certainly one hell of a lousy cleanup logics somewhere.
>
I agree with you.

However, a few months ago it was advocated to let kfree take care of
testing the pointer against NULL and a load of patches like this:

[PATCH] kfree cleanup: drivers/scsi
author Jesper Juhl <jesper.juhl@xxxxxxxxx>
Mon, 7 Nov 2005 09:01:26 +0000 (01:01 -0800)
committer Linus Torvalds <torvalds@xxxxxxxxxxx>
Mon, 7 Nov 2005 15:54:01 +0000 (07:54 -0800)
commit c9475cb0c358ff0dd473544280d92482df491913
tree 091617d0bdab9273d44139c86af21b7540e6d9b1 tree
parent 089b1dbbde28f0f641c20beabba28fa89ab4fab9 commit |
commitdiff
[PATCH] kfree cleanup: drivers/scsi

This is the drivers/scsi/ part of the big kfree cleanup patch.

Remove pointless checks for NULL prior to calling kfree() in
drivers/scsi/.

Signed-off-by: Jesper Juhl <jesper.juhl@xxxxxxxxx>
Cc: James Bottomley <James.Bottomley@xxxxxxxxxxxx>
Acked-by: Kai Makisara <kai.makisara@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxx>


went in. I wonder what will come next when wind changes.

--
Kai
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/