1 /// Use memdup_user rather than duplicating its implementation
2 /// This is a little bit restricted to reduce false positives
5 // Copyright: (C) 2010-2012 Nicolas Palix. GPLv2.
6 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6. GPLv2.
7 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
8 // URL: http://coccinelle.lip6.fr/
10 // Options: -no_includes -include_headers
18 expression from,to,size,flag;
22 - to = \(kmalloc\|kzalloc\)(size,flag);
23 + to = memdup_user(from,size);
28 <+... when != goto l1;
33 - if (copy_from_user(to, from, size) != 0) {
34 - <+... when != goto l2;
40 expression from,to,size,flag;
45 * to = \(kmalloc@p\|kzalloc@p\)(size,flag);
46 if (to==NULL || ...) S1
47 if (copy_from_user(to, from, size) != 0)
50 @script:python depends on org@
54 coccilib.org.print_todo(p[0], "WARNING opportunity for memdep_user")
56 @script:python depends on report@
60 coccilib.report.print_report(p[0], "WARNING opportunity for memdep_user")