diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
| commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
| tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /scripts/coccinelle/free | |
| parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) | |
Patched in Tegra support.
Diffstat (limited to 'scripts/coccinelle/free')
| -rw-r--r-- | scripts/coccinelle/free/clk_put.cocci | 67 | ||||
| -rw-r--r-- | scripts/coccinelle/free/devm_free.cocci | 71 | ||||
| -rw-r--r-- | scripts/coccinelle/free/iounmap.cocci | 67 | ||||
| -rw-r--r-- | scripts/coccinelle/free/kfree.cocci | 14 |
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 | |||
| 14 | virtual context | ||
| 15 | virtual org | ||
| 16 | virtual report | ||
| 17 | |||
| 18 | @clk@ | ||
| 19 | expression e; | ||
| 20 | statement S,S1; | ||
| 21 | int ret; | ||
| 22 | position p1,p2,p3; | ||
| 23 | @@ | ||
| 24 | |||
| 25 | e = clk_get@p1(...) | ||
| 26 | ... when != clk_put(e) | ||
| 27 | if (<+...e...+>) S | ||
| 28 | ... when any | ||
| 29 | when != clk_put(e) | ||
| 30 | when != if (...) { ... clk_put(e); ... } | ||
| 31 | ( | ||
| 32 | if (ret == 0) S1 | ||
| 33 | | | ||
| 34 | if (...) | ||
| 35 | { ... | ||
| 36 | return 0; } | ||
| 37 | | | ||
| 38 | if (...) | ||
| 39 | { ... | ||
| 40 | return <+...e...+>; } | ||
| 41 | | | ||
| 42 | *if@p2 (...) | ||
| 43 | { ... when != clk_put(e) | ||
| 44 | when forall | ||
| 45 | return@p3 ...; } | ||
| 46 | ) | ||
| 47 | ... when any | ||
| 48 | clk_put(e); | ||
| 49 | |||
| 50 | @script:python depends on org@ | ||
| 51 | p1 << clk.p1; | ||
| 52 | p2 << clk.p2; | ||
| 53 | p3 << clk.p3; | ||
| 54 | @@ | ||
| 55 | |||
| 56 | cocci.print_main("clk_get",p1) | ||
| 57 | cocci.print_secs("if",p2) | ||
| 58 | cocci.print_secs("needed clk_put",p3) | ||
| 59 | |||
| 60 | @script:python depends on report@ | ||
| 61 | p1 << clk.p1; | ||
| 62 | p2 << clk.p2; | ||
| 63 | p3 << clk.p3; | ||
| 64 | @@ | ||
| 65 | |||
| 66 | msg = "ERROR: missing clk_put; clk_get on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line) | ||
| 67 | coccilib.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 | |||
| 23 | virtual org | ||
| 24 | virtual report | ||
| 25 | virtual context | ||
| 26 | |||
| 27 | @r depends on context || org || report@ | ||
| 28 | expression 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@ | ||
| 44 | expression r.x; | ||
| 45 | position 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@ | ||
| 59 | p << pb.p; | ||
| 60 | @@ | ||
| 61 | |||
| 62 | msg="WARNING: invalid free of devm_ allocated data" | ||
| 63 | coccilib.org.print_todo(p[0], msg) | ||
| 64 | |||
| 65 | @script:python depends on report@ | ||
| 66 | p << pb.p; | ||
| 67 | @@ | ||
| 68 | |||
| 69 | msg="WARNING: invalid free of devm_ allocated data" | ||
| 70 | coccilib.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 | |||
| 14 | virtual context | ||
| 15 | virtual org | ||
| 16 | virtual report | ||
| 17 | |||
| 18 | @iom@ | ||
| 19 | expression e; | ||
| 20 | statement S,S1; | ||
| 21 | int ret; | ||
| 22 | position p1,p2,p3; | ||
| 23 | @@ | ||
| 24 | |||
| 25 | e = \(ioremap@p1\|ioremap_nocache@p1\)(...) | ||
| 26 | ... when != iounmap(e) | ||
| 27 | if (<+...e...+>) S | ||
| 28 | ... when any | ||
| 29 | when != iounmap(e) | ||
| 30 | when != if (...) { ... iounmap(e); ... } | ||
| 31 | ( | ||
| 32 | if (ret == 0) S1 | ||
| 33 | | | ||
| 34 | if (...) | ||
| 35 | { ... | ||
| 36 | return 0; } | ||
| 37 | | | ||
| 38 | if (...) | ||
| 39 | { ... | ||
| 40 | return <+...e...+>; } | ||
| 41 | | | ||
| 42 | *if@p2 (...) | ||
| 43 | { ... when != iounmap(e) | ||
| 44 | when forall | ||
| 45 | return@p3 ...; } | ||
| 46 | ) | ||
| 47 | ... when any | ||
| 48 | iounmap(e); | ||
| 49 | |||
| 50 | @script:python depends on org@ | ||
| 51 | p1 << iom.p1; | ||
| 52 | p2 << iom.p2; | ||
| 53 | p3 << iom.p3; | ||
| 54 | @@ | ||
| 55 | |||
| 56 | cocci.print_main("ioremap",p1) | ||
| 57 | cocci.print_secs("if",p2) | ||
| 58 | cocci.print_secs("needed iounmap",p3) | ||
| 59 | |||
| 60 | @script:python depends on report@ | ||
| 61 | p1 << iom.p1; | ||
| 62 | p2 << iom.p2; | ||
| 63 | p3 << iom.p3; | ||
| 64 | @@ | ||
| 65 | |||
| 66 | msg = "ERROR: missing iounmap; ioremap on line %s and execution via conditional on line %s" % (p1[0].line,p2[0].line) | ||
| 67 | coccilib.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; | |||
| 23 | kfree@p1(E) | 23 | kfree@p1(E) |
| 24 | 24 | ||
| 25 | @print expression@ | 25 | @print expression@ |
| 26 | constant char [] c; | 26 | constant char *c; |
| 27 | expression free.E,E2; | 27 | expression free.E,E2; |
| 28 | type T; | 28 | type T; |
| 29 | position p; | 29 | position 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; | |||
| 117 | p2 << r.p2; | 113 | p2 << r.p2; |
| 118 | @@ | 114 | @@ |
| 119 | 115 | ||
| 120 | msg = "ERROR: reference preceded by free on line %s" % (p1[0].line) | 116 | msg = "reference preceded by free on line %s" % (p1[0].line) |
| 121 | coccilib.report.print_report(p2[0],msg) | 117 | coccilib.report.print_report(p2[0],msg) |
