qeth: Use memdup_user when user data is immediately copied into the allocated region.
authorJulia Lawall <julia@diku.dk>
Thu, 22 Jul 2010 23:15:09 +0000 (23:15 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 23 Jul 2010 19:36:25 +0000 (12:36 -0700)
commit4986f3f01aca9a332fa8e0fc9fdf3338791ee374
tree6e721db6a2ebe00901725fd0bc1889339d736943
parentbbb822a8c032813148888fcec85e89edb17286d3
qeth: Use memdup_user when user data is immediately copied into the allocated region.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression from,to,size,flag;
position p;
identifier l1,l2;
@@

-  to = \(kmalloc@p\|kzalloc@p\)(size,flag);
+  to = memdup_user(from,size);
   if (
-      to==NULL
+      IS_ERR(to)
                 || ...) {
   <+... when != goto l1;
-  -ENOMEM
+  PTR_ERR(to)
   ...+>
   }
-  if (copy_from_user(to, from, size) != 0) {
-    <+... when != goto l2;
-    -EFAULT
-    ...+>
-  }
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_core_main.c