Re: [PATCH] ext3_clear_inode(): avoid kfree(NULL)

From: Andrew Morton
Date: Fri Jun 23 2006 - 17:23:14 EST


On Fri, 23 Jun 2006 14:51:03 -0400
Jeff Garzik <jeff@xxxxxxxxxx> wrote:

> Linux Kernel Mailing List wrote:
> > commit e6022603b9aa7d61d20b392e69edcdbbc1789969
> > tree f94b059e312ea7b2f3c4d0b01939e868ed525fb0
> > parent 304c4c841a31c780a45d65e389b07706babf5d36
> > author Andrew Morton <akpm@xxxxxxxx> Fri, 23 Jun 2006 16:05:32 -0700
> > committer Linus Torvalds <torvalds@xxxxxxxxxxx> Fri, 23 Jun 2006 21:43:05 -0700
> >
> > [PATCH] ext3_clear_inode(): avoid kfree(NULL)
> >
> > Steven Rostedt <rostedt@xxxxxxxxxxx> points out that `rsv' here is usually
> > NULL, so we should avoid calling kfree().
> >
> > Also, fix up some nearby whitespace damage.
> >
> > Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
> > Signed-off-by: Linus Torvalds <torvalds@xxxxxxxx>
>
> Dumb question... why? kfree(NULL) has always been explicitly allowed.
>

Because at that callsite, NULL is the common case. We avoid a do-nothing
function call most of the time. It's a nano-optimisation.
-
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/