summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2018-02-01 10:48:52 +0100
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-02-07 23:53:09 +0900
commite856f3a7d706b37d8be9b41e41b19f4919570e57 (patch)
treeb26c47ce8d86c2ca2dc8f9d6a25467dfa939f0fa /scripts
parent0a5f41767444cc3b4fc5573921ab914b4f78baaa (diff)
downloadlinux-e856f3a7d706b37d8be9b41e41b19f4919570e57.tar.gz
linux-e856f3a7d706b37d8be9b41e41b19f4919570e57.tar.bz2
linux-e856f3a7d706b37d8be9b41e41b19f4919570e57.zip
coccinelle: devm_free: reduce false positives
Some files use both a non-devm allocation and a devm_allocation. Don't complain about a free when the same function contains a non-devm allocation. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/coccinelle/free/devm_free.cocci55
1 files changed, 54 insertions, 1 deletions
diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci
index c990d2c7ee16..b2a2cf8bf81f 100644
--- a/scripts/coccinelle/free/devm_free.cocci
+++ b/scripts/coccinelle/free/devm_free.cocci
@@ -56,9 +56,62 @@ expression x;
x = devm_ioport_map(...)
)
+@safe depends on context || org || report exists@
+expression x;
+position p;
+@@
+
+(
+ x = kmalloc(...)
+|
+ x = kvasprintf(...)
+|
+ x = kasprintf(...)
+|
+ x = kzalloc(...)
+|
+ x = kmalloc_array(...)
+|
+ x = kcalloc(...)
+|
+ x = kstrdup(...)
+|
+ x = kmemdup(...)
+|
+ x = get_free_pages(...)
+|
+ x = request_irq(...)
+|
+ x = ioremap(...)
+|
+ x = ioremap_nocache(...)
+|
+ x = ioport_map(...)
+)
+...
+(
+ kfree@p(x)
+|
+ kzfree@p(x)
+|
+ __krealloc@p(x, ...)
+|
+ krealloc@p(x, ...)
+|
+ free_pages@p(x, ...)
+|
+ free_page@p(x)
+|
+ free_irq@p(x)
+|
+ iounmap@p(x)
+|
+ ioport_unmap@p(x)
+)
+
@pb@
expression r.x;
-position p;
+position p != safe.p;
@@
(