lkml.org 
[lkml]   [2005]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: p = kmalloc(sizeof(*p), )
On Tue, Sep 20, 2005 at 12:47:32PM +0300, Pekka J Enberg wrote:
> > To find candidates, something like:
> >
> > grep "kmalloc(sizeof([^*]" -r drivers/ | grep -v "sizeof(struct"
> >
> > And then use my eyes to find real bugs.

On Tue, 20 Sep 2005, Al Viro wrote:
> "grep for kmallocs that do not have _either_ form and look for bugs among
> them" is hardly usable as an argument in favour of one of them...

I would disagree with that. The _common case_ for allocation is:

p = kmalloc(sizeof(*p), ...);

For which you know that you are allocating enough memory for the struct.
Now the only way to screw it up is to write:

p = kmalloc(sizeof(p), ...);

That is trivial to grep for.

Yes, currently, typedefs and open-coded kcalloc's give false positives but
that's what kernel janitors are for...

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

\
 
 \ /
  Last update: 2005-09-20 12:10    [W:0.133 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site