Skip to content

Commit 547ade4

Browse files
evdenisJuliaLawall
authored andcommitted
coccinelle: api: extend memdup_user transformation with GFP_USER
Match GFP_USER and optional __GFP_NOWARN allocations with memdup_user.cocci rule. Commit 6c2c97a ("memdup_user(): switch to GFP_USER") switched memdup_user() from GFP_KERNEL to GFP_USER. In almost all cases it is still a good idea to recommend memdup_user() for GFP_KERNEL allocations. The motivation behind altering memdup_user() to GFP_USER: https://lkml.org/lkml/2018/1/6/333 Signed-off-by: Denis Efremov <[email protected]> Signed-off-by: Julia Lawall <[email protected]>
1 parent 7cf4be6 commit 547ade4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/coccinelle/api/memdup_user.cocci

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ expression from,to,size;
2020
identifier l1,l2;
2121
@@
2222

23-
- to = \(kmalloc\|kzalloc\)(size,GFP_KERNEL);
23+
- to = \(kmalloc\|kzalloc\)
24+
- (size,\(GFP_KERNEL\|GFP_USER\|
25+
- \(GFP_KERNEL\|GFP_USER\)|__GFP_NOWARN\));
2426
+ to = memdup_user(from,size);
2527
if (
2628
- to==NULL
@@ -43,7 +45,9 @@ position p;
4345
statement S1,S2;
4446
@@
4547

46-
* to = \(kmalloc@p\|kzalloc@p\)(size,GFP_KERNEL);
48+
* to = \(kmalloc@p\|kzalloc@p\)
49+
(size,\(GFP_KERNEL\|GFP_USER\|
50+
\(GFP_KERNEL\|GFP_USER\)|__GFP_NOWARN\));
4751
if (to==NULL || ...) S1
4852
if (copy_from_user(to, from, size) != 0)
4953
S2

0 commit comments

Comments
 (0)