diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-15 21:22:38 (GMT) |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2010-05-16 03:05:07 (GMT) |
commit | 9893e742a0d942dda2277e9f3e19b726900adf27 (patch) | |
tree | a66503c6469511e0d9671c52155ab835c15cdb5a /drivers/infiniband/core/mad.c | |
parent | 0eddb519b9127c73d53db4bf3ec1d45b13f844d1 (diff) | |
download | linux-fsl-qoriq-9893e742a0d942dda2277e9f3e19b726900adf27.tar.xz |
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>
Diffstat (limited to 'drivers/infiniband/core/mad.c')
-rw-r--r-- | drivers/infiniband/core/mad.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index 1df1194..6dc7b77 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c @@ -291,13 +291,11 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, } if (mad_reg_req) { - reg_req = kmalloc(sizeof *reg_req, GFP_KERNEL); + reg_req = kmemdup(mad_reg_req, sizeof *reg_req, GFP_KERNEL); if (!reg_req) { ret = ERR_PTR(-ENOMEM); goto error3; } - /* Make a copy of the MAD registration request */ - memcpy(reg_req, mad_reg_req, sizeof *reg_req); } /* Now, fill in the various structures */ |