aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2016-09-21 11:48:39 -0400
committerMichal Marek <mmarek@suse.com>2016-10-01 17:03:09 -0400
commit43d96390d57aa0e61d15ce2bcb887df8516d58f5 (patch)
treeba3d86262a4c413d26982a117eb43b0cd185bfba /scripts
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
Coccinelle: limit memdup_user transformation to GFP_KERNEL case
Memdup_user encapsulates a memory allocation with the flag GFP_KERNEL, so only allow this flag in the original code. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/coccinelle/api/memdup_user.cocci8
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci
index c606231b0e46..2a5aea8e8487 100644
--- a/scripts/coccinelle/api/memdup_user.cocci
+++ b/scripts/coccinelle/api/memdup_user.cocci
@@ -15,11 +15,11 @@ virtual org
15virtual report 15virtual report
16 16
17@depends on patch@ 17@depends on patch@
18expression from,to,size,flag; 18expression from,to,size;
19identifier l1,l2; 19identifier l1,l2;
20@@ 20@@
21 21
22- to = \(kmalloc\|kzalloc\)(size,flag); 22- to = \(kmalloc\|kzalloc\)(size,GFP_KERNEL);
23+ to = memdup_user(from,size); 23+ to = memdup_user(from,size);
24 if ( 24 if (
25- to==NULL 25- to==NULL
@@ -37,12 +37,12 @@ identifier l1,l2;
37- } 37- }
38 38
39@r depends on !patch@ 39@r depends on !patch@
40expression from,to,size,flag; 40expression from,to,size;
41position p; 41position p;
42statement S1,S2; 42statement S1,S2;
43@@ 43@@
44 44
45* to = \(kmalloc@p\|kzalloc@p\)(size,flag); 45* to = \(kmalloc@p\|kzalloc@p\)(size,GFP_KERNEL);
46 if (to==NULL || ...) S1 46 if (to==NULL || ...) S1
47 if (copy_from_user(to, from, size) != 0) 47 if (copy_from_user(to, from, size) != 0)
48 S2 48 S2