aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/coccinelle/free
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /scripts/coccinelle/free
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'scripts/coccinelle/free')
-rw-r--r--scripts/coccinelle/free/clk_put.cocci67
-rw-r--r--scripts/coccinelle/free/devm_free.cocci71
-rw-r--r--scripts/coccinelle/free/iounmap.cocci67
-rw-r--r--scripts/coccinelle/free/kfree.cocci14
4 files changed, 5 insertions, 214 deletions
diff --git a/scripts/coccinelle/free/clk_put.cocci b/scripts/coccinelle/free/clk_put.cocci
deleted file mode 100644
index 46747adfd20..00000000000
--- a/scripts/coccinelle/free/clk_put.cocci
+++ /dev/null
@@ -1,67 +0,0 @@
1/// Find missing clk_puts.
2///
3//# This only signals a missing clk_put when there is a clk_put later
4//# in the same function.
5//# False positives can be due to loops.
6//
7// Confidence: Moderate
8// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
9// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
10// URL: http://coccinelle.lip6.fr/
11// Comments:
12// Options:
13
14virtual context
15virtual org
16virtual report
17
18@clk@
19expression e;
20statement S,S1;
21int ret;
22position p1,p2,p3;
23@@
24
25e = clk_get@p1(...)
26... when != clk_put(e)
27if (<+...e...+>) S
28... when any
29 when != clk_put(e)
30 when != if (...) { ... clk_put(e); ... }
31(
32 if (ret == 0) S1
33|
34if (...)
35 { ...
36 return 0; }
37|
38if (...)
39 { ...
40 return <+...e...+>; }
41|
42*if@p2 (...)
43 { ... when != clk_put(e)
44 when forall
45 return@p3 ...; }
46)
47... when any
48clk_put(e);
49
50@script:python depends on org@
51p1 << clk.p1;
52p2 << clk.p2;
53p3 << clk.p3;
54@@
55
56cocci.print_main("clk_get",p1)
57cocci.print_secs("if",p2)
58cocci.print_secs("needed clk_put",p3)
59
60@script:python depends on report@
61p1 << clk.p1;
62p2 << clk.p2;
63p3 << clk.p3;
64@@
65
66msg = "ERROR: missing clk_put; clk_get on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line)
67coccilib.report.print_report(p3[0],msg)
diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci
deleted file mode 100644
index 0a1e36146d7..00000000000
--- a/scripts/coccinelle/free/devm_free.cocci
+++ /dev/null
@@ -1,71 +0,0 @@
1/// Find uses of standard freeing functons on values allocated using devm_
2/// functions. Values allocated using the devm_functions are freed when
3/// the device is detached, and thus the use of the standard freeing
4/// function would cause a double free.
5/// See Documentation/driver-model/devres.txt for more information.
6///
7/// A difficulty of detecting this problem is that the standard freeing
8/// function might be called from a different function than the one
9/// containing the allocation function. It is thus necessary to make the
10/// connection between the allocation function and the freeing function.
11/// Here this is done using the specific argument text, which is prone to
12/// false positives. There is no rule for the request_region and
13/// request_mem_region variants because this heuristic seems to be a bit
14/// less reliable in these cases.
15///
16// Confidence: Moderate
17// Copyright: (C) 2011 Julia Lawall, INRIA/LIP6. GPLv2.
18// Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2.
19// URL: http://coccinelle.lip6.fr/
20// Comments:
21// Options: -no_includes -include_headers
22
23virtual org
24virtual report
25virtual context
26
27@r depends on context || org || report@
28expression x;
29@@
30
31(
32 x = devm_kzalloc(...)
33|
34 x = devm_request_irq(...)
35|
36 x = devm_ioremap(...)
37|
38 x = devm_ioremap_nocache(...)
39|
40 x = devm_ioport_map(...)
41)
42
43@pb@
44expression r.x;
45position p;
46@@
47
48(
49* kfree@p(x)
50|
51* free_irq@p(x)
52|
53* iounmap@p(x)
54|
55* ioport_unmap@p(x)
56)
57
58@script:python depends on org@
59p << pb.p;
60@@
61
62msg="WARNING: invalid free of devm_ allocated data"
63coccilib.org.print_todo(p[0], msg)
64
65@script:python depends on report@
66p << pb.p;
67@@
68
69msg="WARNING: invalid free of devm_ allocated data"
70coccilib.report.print_report(p[0], msg)
71
diff --git a/scripts/coccinelle/free/iounmap.cocci b/scripts/coccinelle/free/iounmap.cocci
deleted file mode 100644
index 5384f4ba119..00000000000
--- a/scripts/coccinelle/free/iounmap.cocci
+++ /dev/null
@@ -1,67 +0,0 @@
1/// Find missing iounmaps.
2///
3//# This only signals a missing iounmap when there is an iounmap later
4//# in the same function.
5//# False positives can be due to loops.
6//
7// Confidence: Moderate
8// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
9// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
10// URL: http://coccinelle.lip6.fr/
11// Comments:
12// Options:
13
14virtual context
15virtual org
16virtual report
17
18@iom@
19expression e;
20statement S,S1;
21int ret;
22position p1,p2,p3;
23@@
24
25e = \(ioremap@p1\|ioremap_nocache@p1\)(...)
26... when != iounmap(e)
27if (<+...e...+>) S
28... when any
29 when != iounmap(e)
30 when != if (...) { ... iounmap(e); ... }
31(
32 if (ret == 0) S1
33|
34if (...)
35 { ...
36 return 0; }
37|
38if (...)
39 { ...
40 return <+...e...+>; }
41|
42*if@p2 (...)
43 { ... when != iounmap(e)
44 when forall
45 return@p3 ...; }
46)
47... when any
48iounmap(e);
49
50@script:python depends on org@
51p1 << iom.p1;
52p2 << iom.p2;
53p3 << iom.p3;
54@@
55
56cocci.print_main("ioremap",p1)
57cocci.print_secs("if",p2)
58cocci.print_secs("needed iounmap",p3)
59
60@script:python depends on report@
61p1 << iom.p1;
62p2 << iom.p2;
63p3 << iom.p3;
64@@
65
66msg = "ERROR: missing iounmap; ioremap on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line)
67coccilib.report.print_report(p3[0],msg)
diff --git a/scripts/coccinelle/free/kfree.cocci b/scripts/coccinelle/free/kfree.cocci
index d9ae6d89c2f..f9f79d9245e 100644
--- a/scripts/coccinelle/free/kfree.cocci
+++ b/scripts/coccinelle/free/kfree.cocci
@@ -5,9 +5,9 @@
5//# SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument 5//# SCTP_DBG_OBJCNT_DEC that do not actually evaluate their argument
6/// 6///
7// Confidence: Moderate 7// Confidence: Moderate
8// Copyright: (C) 2010-2012 Nicolas Palix. GPLv2. 8// Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
9// Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2. 9// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
10// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 10// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/ 11// URL: http://coccinelle.lip6.fr/
12// Comments: 12// Comments:
13// Options: -no_includes -include_headers 13// Options: -no_includes -include_headers
@@ -23,7 +23,7 @@ position p1;
23kfree@p1(E) 23kfree@p1(E)
24 24
25@print expression@ 25@print expression@
26constant char [] c; 26constant char *c;
27expression free.E,E2; 27expression free.E,E2;
28type T; 28type T;
29position p; 29position p;
@@ -37,10 +37,6 @@ identifier f;
37| 37|
38 E@p != E2 38 E@p != E2
39| 39|
40 E2 == E@p
41|
42 E2 != E@p
43|
44 !E@p 40 !E@p
45| 41|
46 E@p || ... 42 E@p || ...
@@ -117,5 +113,5 @@ p1 << free.p1;
117p2 << r.p2; 113p2 << r.p2;
118@@ 114@@
119 115
120msg = "ERROR: reference preceded by free on line %s" % (p1[0].line) 116msg = "reference preceded by free on line %s" % (p1[0].line)
121coccilib.report.print_report(p2[0],msg) 117coccilib.report.print_report(p2[0],msg)