pseries/iommu: Add missing kfree
authorJulia Lawall <julia@diku.dk>
Mon, 8 Aug 2011 01:18:00 +0000 (01:18 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 19 Sep 2011 23:19:49 +0000 (09:19 +1000)
commit7a19081fc2658157a1b84e6f3288450c33d98569
treed76a01044ddba8ce3136729b217706663055db75
parent6dece0eb69b2a28e18d104bc5d707f1cb673f5e0
pseries/iommu: Add missing kfree

At this point, window has not been stored anywhere, so it has to be freed
before leaving the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@exists@
local idexpression x;
statement S,S1;
expression E;
identifier fl;
expression *ptr != NULL;
@@

x = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
     when != if (...) { <+...kfree(x)...+> }
     when any
     when != true x == NULL
x->fl
...>
(
if (x == NULL) S1
|
if (...) { ... when != x
               when forall
(
 return \(0\|<+...x...+>\|ptr\);
|
* return ...;
)
}
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/platforms/pseries/iommu.c