From 61cb48c3f93adee633f996dd40ff5267fae55b3a Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 8 Jun 2013 18:21:42 +0200 Subject: scripts/coccinelle: check for field address argument to kfree The argument to kfree should not be the address of a structure field. Signed-off-by: Julia Lawall Signed-off-by: Michal Marek --- scripts/coccinelle/free/kfreeaddr.cocci | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/coccinelle/free/kfreeaddr.cocci (limited to 'scripts/coccinelle') diff --git a/scripts/coccinelle/free/kfreeaddr.cocci b/scripts/coccinelle/free/kfreeaddr.cocci new file mode 100644 index 000000000000..662e997da834 --- /dev/null +++ b/scripts/coccinelle/free/kfreeaddr.cocci @@ -0,0 +1,32 @@ +/// Free of a structure field +/// +// Confidence: High +// Copyright: (C) 2013 Julia Lawall, INRIA/LIP6. GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Comments: +// Options: -no_includes -include_headers + +virtual org +virtual report +virtual context + +@r depends on context || report || org @ +expression e; +identifier f; +position p; +@@ + +* kfree@p(&e->f) + +@script:python depends on org@ +p << r.p; +@@ + +cocci.print_main("kfree",p) + +@script:python depends on report@ +p << r.p; +@@ + +msg = "ERROR: kfree of structure field" +coccilib.report.print_report(p[0],msg) -- cgit v1.2.3