Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1335685 > unrolled thread
| Started by | Yann Droneaud <ydroneaud@opteya.com> |
|---|---|
| First post | 2016-02-16 19:00 +0100 |
| Last post | 2016-02-16 19:00 +0100 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 0/3] coccinelle: catchup on memory allocation functions Yann Droneaud <ydroneaud@opteya.com> - 2016-02-16 19:00 +0100
[PATCH 1/3] coccinelle: also catch kzfree() issues Yann Droneaud <ydroneaud@opteya.com> - 2016-02-16 19:00 +0100
| From | Yann Droneaud <ydroneaud@opteya.com> |
|---|---|
| Date | 2016-02-16 19:00 +0100 |
| Subject | [PATCH 0/3] coccinelle: catchup on memory allocation functions |
| Message-ID | <r2Rs6-2q8-19@gated-at.bofh.it> |
Hi, Please find few patches that remove coccicheck's blindness regarding the following functions: - kzfree() - krealloc() - __krealloc() - devm_kmalloc() - devm_kvasprintf() - devm_kasprintf() - devm_kmalloc_array() - devm_kcalloc() - devm_kstrdup() - devm_kmemdup() - devm_get_free_pages() - free_pages() - free_page() I've ran coccicheck on drivers/staging and found no new issue, which is great, but that questions those patches' usefulness, YMMV. Regards. Yann Droneaud (3): coccinelle: also catch kzfree() issues coccinelle: recognize more devm_* memory allocation functions coccinelle: catch krealloc() on devm_*() allocated memory scripts/coccinelle/free/devm_free.cocci | 26 ++++++++++++++++++++++++++ scripts/coccinelle/free/kfree.cocci | 3 +++ scripts/coccinelle/free/kfreeaddr.cocci | 6 +++++- 3 files changed, 34 insertions(+), 1 deletion(-) -- 2.5.0
[toc] | [next] | [standalone]
| From | Yann Droneaud <ydroneaud@opteya.com> |
|---|---|
| Date | 2016-02-16 19:00 +0100 |
| Subject | [PATCH 1/3] coccinelle: also catch kzfree() issues |
| Message-ID | <r2Rs6-2q8-25@gated-at.bofh.it> |
| In reply to | #1335685 |
Since commit 3ef0e5ba4673 ('slab: introduce kzfree()'),
kfree() is no more the only function to be considered.
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
---
scripts/coccinelle/free/devm_free.cocci | 2 ++
scripts/coccinelle/free/kfree.cocci | 3 +++
scripts/coccinelle/free/kfreeaddr.cocci | 6 +++++-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci
index 3d9349012bb3..83c03adec1c5 100644
--- a/scripts/coccinelle/free/devm_free.cocci
+++ b/scripts/coccinelle/free/devm_free.cocci
@@ -48,6 +48,8 @@ position p;
(
* kfree@p(x)
|
+* kzfree@p(x)
+|
* free_irq@p(x)
|
* iounmap@p(x)
diff --git a/scripts/coccinelle/free/kfree.cocci b/scripts/coccinelle/free/kfree.cocci
index 577b78056990..c3246b47f51f 100644
--- a/scripts/coccinelle/free/kfree.cocci
+++ b/scripts/coccinelle/free/kfree.cocci
@@ -16,6 +16,7 @@ virtual org
virtual report
@free@
+identifier kfree =~ "kz?free";
expression E;
position p1;
@@
@@ -54,6 +55,7 @@ position p;
sizeof(<+...E@p...+>)
@loop exists@
+identifier kfree =~ "kz?free";
expression E;
identifier l;
position ok;
@@ -67,6 +69,7 @@ while (1) { ...
}
@r exists@
+identifier kfree =~ "kz?free";
expression free.E, subE<=free.E, E2;
expression E1;
iterator iter;
diff --git a/scripts/coccinelle/free/kfreeaddr.cocci b/scripts/coccinelle/free/kfreeaddr.cocci
index ce8aacc314cb..d46063b1db8b 100644
--- a/scripts/coccinelle/free/kfreeaddr.cocci
+++ b/scripts/coccinelle/free/kfreeaddr.cocci
@@ -16,7 +16,11 @@ identifier f;
position p;
@@
+(
* kfree@p(&e->f)
+|
+* kzfree@p(&e->f)
+)
@script:python depends on org@
p << r.p;
@@ -28,5 +32,5 @@ cocci.print_main("kfree",p)
p << r.p;
@@
-msg = "ERROR: kfree of structure field"
+msg = "ERROR: invalid free of structure field"
coccilib.report.print_report(p[0],msg)
--
2.5.0
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web