Skip to content

Commit d05f94a

Browse files
evdenisJuliaLawall
authored andcommitted
coccinelle: api: filter out memdup_user definitions
Don't match memdup_user/vmemdup_user. Signed-off-by: Denis Efremov <[email protected]> Signed-off-by: Julia Lawall <[email protected]>
1 parent 9c568db commit d05f94a

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

scripts/coccinelle/api/memdup_user.cocci

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ virtual context
1515
virtual org
1616
virtual report
1717

18+
@initialize:python@
19+
@@
20+
filter = frozenset(['memdup_user', 'vmemdup_user'])
21+
22+
def relevant(p):
23+
return not (filter & {el.current_element for el in p})
24+
1825
@depends on patch@
1926
expression from,to,size;
2027
identifier l1,l2;
28+
position p : script:python() { relevant(p) };
2129
@@
2230

23-
- to = \(kmalloc\|kzalloc\)
31+
- to = \(kmalloc@p\|kzalloc@p\)
2432
- (size,\(GFP_KERNEL\|GFP_USER\|
2533
- \(GFP_KERNEL\|GFP_USER\)|__GFP_NOWARN\));
2634
+ to = memdup_user(from,size);
@@ -42,9 +50,10 @@ identifier l1,l2;
4250
@depends on patch@
4351
expression from,to,size;
4452
identifier l1,l2;
53+
position p : script:python() { relevant(p) };
4554
@@
4655

47-
- to = \(kvmalloc\|kvzalloc\)(size,\(GFP_KERNEL\|GFP_USER\));
56+
- to = \(kvmalloc@p\|kvzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\));
4857
+ to = vmemdup_user(from,size);
4958
if (
5059
- to==NULL
@@ -63,7 +72,7 @@ identifier l1,l2;
6372

6473
@r depends on !patch@
6574
expression from,to,size;
66-
position p;
75+
position p : script:python() { relevant(p) };
6776
statement S1,S2;
6877
@@
6978

@@ -76,7 +85,7 @@ statement S1,S2;
7685

7786
@rv depends on !patch@
7887
expression from,to,size;
79-
position p;
88+
position p : script:python() { relevant(p) };
8089
statement S1,S2;
8190
@@
8291

0 commit comments

Comments
 (0)