Bluetooth: Replaced kzalloc and memcpy with kmemdup
authorAlexandru Gheorghiu <gheorghiuandru@gmail.com>
Sun, 17 Mar 2013 05:16:50 +0000 (07:16 +0200)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>
Mon, 18 Mar 2013 17:01:50 +0000 (14:01 -0300)
Replaced calls to kzalloc followed by memcpy with a single call to kmemdup.

Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
net/bluetooth/a2mp.c

index eb0f4b16ff099611fb6ea0aa43add29bd1c1173f..17f33a62f6db559824d9dc1b3973acb779fa9162 100644 (file)
@@ -397,13 +397,12 @@ static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
        if (ctrl) {
                u8 *assoc;
 
-               assoc = kzalloc(assoc_len, GFP_KERNEL);
+               assoc = kmemdup(rsp->amp_assoc, assoc_len, GFP_KERNEL);
                if (!assoc) {
                        amp_ctrl_put(ctrl);
                        return -ENOMEM;
                }
 
-               memcpy(assoc, rsp->amp_assoc, assoc_len);
                ctrl->assoc = assoc;
                ctrl->assoc_len = assoc_len;
                ctrl->assoc_rem_len = assoc_len;
@@ -472,13 +471,12 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
                size_t assoc_len = le16_to_cpu(hdr->len) - sizeof(*req);
                u8 *assoc;
 
-               assoc = kzalloc(assoc_len, GFP_KERNEL);
+               assoc = kmemdup(req->amp_assoc, assoc_len, GFP_KERNEL);
                if (!assoc) {
                        amp_ctrl_put(ctrl);
                        return -ENOMEM;
                }
 
-               memcpy(assoc, req->amp_assoc, assoc_len);
                ctrl->assoc = assoc;
                ctrl->assoc_len = assoc_len;
                ctrl->assoc_rem_len = assoc_len;