aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2018-02-01 04:48:52 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-02-07 09:53:09 -0500
commite856f3a7d706b37d8be9b41e41b19f4919570e57 (patch)
treeb26c47ce8d86c2ca2dc8f9d6a25467dfa939f0fa
parent0a5f41767444cc3b4fc5573921ab914b4f78baaa (diff)
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>
-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;
56 x = devm_ioport_map(...) 56 x = devm_ioport_map(...)
57) 57)
58 58
59@safe depends on context || org || report exists@
60expression x;
61position p;
62@@
63
64(
65 x = kmalloc(...)
66|
67 x = kvasprintf(...)
68|
69 x = kasprintf(...)
70|
71 x = kzalloc(...)
72|
73 x = kmalloc_array(...)
74|
75 x = kcalloc(...)
76|
77 x = kstrdup(...)
78|
79 x = kmemdup(...)
80|
81 x = get_free_pages(...)
82|
83 x = request_irq(...)
84|
85 x = ioremap(...)
86|
87 x = ioremap_nocache(...)
88|
89 x = ioport_map(...)
90)
91...
92(
93 kfree@p(x)
94|
95 kzfree@p(x)
96|
97 __krealloc@p(x, ...)
98|
99 krealloc@p(x, ...)
100|
101 free_pages@p(x, ...)
102|
103 free_page@p(x)
104|
105 free_irq@p(x)
106|
107 iounmap@p(x)
108|
109 ioport_unmap@p(x)
110)
111
59@pb@ 112@pb@
60expression r.x; 113expression r.x;
61position p; 114position p != safe.p;
62@@ 115@@
63 116
64( 117(