summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDenis Efremov <efremov@linux.com>2020-07-20 19:22:16 +0300
committerJulia Lawall <Julia.Lawall@lip6.fr>2020-08-04 22:46:59 +0200
commitd05f94ad28c76cbd98aecee8e617f18454050f57 (patch)
tree0cf7df614138125828377ba44d7adc314612493a /scripts
parent9c568dbd677bcfc975220d3157c89c48669a23e3 (diff)
coccinelle: api: filter out memdup_user definitions
Don't match memdup_user/vmemdup_user. Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/coccinelle/api/memdup_user.cocci17
1 files changed, 13 insertions, 4 deletions
diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci
index 60027e21c5e6..e01e95108405 100644
--- a/scripts/coccinelle/api/memdup_user.cocci
+++ b/scripts/coccinelle/api/memdup_user.cocci
@@ -15,12 +15,20 @@ virtual context
virtual org
virtual report
+@initialize:python@
+@@
+filter = frozenset(['memdup_user', 'vmemdup_user'])
+
+def relevant(p):
+ return not (filter & {el.current_element for el in p})
+
@depends on patch@
expression from,to,size;
identifier l1,l2;
+position p : script:python() { relevant(p) };
@@
-- to = \(kmalloc\|kzalloc\)
+- to = \(kmalloc@p\|kzalloc@p\)
- (size,\(GFP_KERNEL\|GFP_USER\|
- \(GFP_KERNEL\|GFP_USER\)|__GFP_NOWARN\));
+ to = memdup_user(from,size);
@@ -42,9 +50,10 @@ identifier l1,l2;
@depends on patch@
expression from,to,size;
identifier l1,l2;
+position p : script:python() { relevant(p) };
@@
-- to = \(kvmalloc\|kvzalloc\)(size,\(GFP_KERNEL\|GFP_USER\));
+- to = \(kvmalloc@p\|kvzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\));
+ to = vmemdup_user(from,size);
if (
- to==NULL
@@ -63,7 +72,7 @@ identifier l1,l2;
@r depends on !patch@
expression from,to,size;
-position p;
+position p : script:python() { relevant(p) };
statement S1,S2;
@@
@@ -76,7 +85,7 @@ statement S1,S2;
@rv depends on !patch@
expression from,to,size;
-position p;
+position p : script:python() { relevant(p) };
statement S1,S2;
@@