IB/core: Use kmemdup() instead of kmalloc()+memcpy()
authorJulia Lawall <julia@diku.dk>
Sat, 15 May 2010 21:22:38 +0000 (23:22 +0200)
committerRoland Dreier <rolandd@cisco.com>
Sun, 16 May 2010 03:05:07 +0000 (20:05 -0700)
commit9893e742a0d942dda2277e9f3e19b726900adf27
treea66503c6469511e0d9671c52155ab835c15cdb5a
parent0eddb519b9127c73d53db4bf3ec1d45b13f844d1
IB/core: Use kmemdup() instead of kmalloc()+memcpy()

Use kmemdup when some other buffer is immediately copied into the
allocated region.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression from,to,size,flag;
statement S;
@@

-  to = \(kmalloc\|kzalloc\)(size,flag);
+  to = kmemdup(from,size,flag);
   if (to==NULL || ...) S
-  memcpy(to, from, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/cma.c
drivers/infiniband/core/mad.c