Skip to content

Commit

Permalink
coccinelle: api: filter out memdup_user definitions
Browse files Browse the repository at this point in the history
Don't match memdup_user/vmemdup_user.

Signed-off-by: Denis Efremov <efremov@linux.com>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
  • Loading branch information
evdenis authored and JuliaLawall committed Aug 4, 2020
1 parent 9c568db commit d05f94a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions scripts/coccinelle/api/memdup_user.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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;
@@

Expand All @@ -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;
@@

Expand Down

0 comments on commit d05f94a

Please sign in to comment.