IB/core: Use kmemdup() instead of kmalloc()+memcpy()
[safe/jmp/linux-2.6] / drivers / infiniband / core / mad.c
index 1df1194..6dc7b77 100644 (file)
@@ -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 */