]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/fsl_rio: Add kmalloc NULL tests
authorJulia Lawall <julia@diku.dk>
Fri, 7 Aug 2009 07:00:34 +0000 (09:00 +0200)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 20 Aug 2009 00:27:17 +0000 (10:27 +1000)
commitbb3fe166b55adb5fd8208171bcef8efe4a297a4b
tree57618062dd88af2c186610a5f880df48257f8d24
parentff56370021d15370e442c6cc9ead921a725c6155
powerpc/fsl_rio: Add kmalloc NULL tests

Check that the result of kmalloc/kzalloc is not NULL before dereferencing it.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression *x;
identifier f;
constant char *C;
@@

x = \(kmalloc\|kcalloc\|kzalloc\)(...);
... when != x == NULL
    when != x != NULL
    when != (x || ...)
(
kfree(x)
|
f(...,C,...,x,...)
|
*f(...,x,...)
|
*x->f
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/sysdev/fsl_rio.c