linux/arch/powerpc
Julia Lawall 3475dd8a68 powerpc/qe: introduce missing kfree
Error handling code following a kzalloc should free the allocated data.

The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,f1,l;
position p1,p2;
expression *ptr != NULL;
@@

x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
     when != if (...) { <+...x...+> }
(
x->f1 = E
|
 (x->f1 == NULL || ...)
|
 f(...,x->f1,...)
)
...>
(
 return \(0\|<+...x...+>\|ptr\);
|
 return@p2 ...;
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2009-08-20 10:27:38 +10:00
..
boot powerpc/82xx: mgcoge - updates for 2.6.32 2009-08-20 10:27:30 +10:00
configs powerpc/40x: Update kilauea defconfig to support NAND, RTC and HWMON 2009-08-20 10:25:52 +10:00
include/asm powerpc/mm: Fix encoding of page table cache numbers 2009-08-20 10:25:12 +10:00
kernel powerpc: Add AMCC 460EX/460GT Rev. B support to cputable.c 2009-08-20 10:25:18 +10:00
kvm powerpc: Use names rather than numbers for SPRGs (v2) 2009-08-20 10:12:27 +10:00
lib powerpc: Add configurable -Werror for arch/powerpc 2009-06-16 14:15:45 +10:00
math-emu powerpc/math-emu: Fix efp dependence 2009-03-11 06:00:08 -05:00
mm powerpc/fsl-booke: read buffer overflow 2009-08-20 10:27:12 +10:00
oprofile powerpc: Remove unnecessary semicolons 2009-07-08 13:50:21 +10:00
platforms powerpc/82xx: mgcoge - updates for 2.6.32 2009-08-20 10:27:30 +10:00
sysdev powerpc/qe: introduce missing kfree 2009-08-20 10:27:38 +10:00
xmon powerpc: Remaining 64-bit Book3E support 2009-08-20 10:25:11 +10:00
Kconfig powerpc: Remaining 64-bit Book3E support 2009-08-20 10:25:11 +10:00
Kconfig.debug powerpc: Add configurable -Werror for arch/powerpc 2009-06-16 14:15:45 +10:00
Makefile powerpc: Makefile simplification through use of cc-ifversion 2009-08-20 10:12:33 +10:00