Commit 5ae327f0 authored by Alexandru Gheorghiu's avatar Alexandru Gheorghiu Committed by Gustavo Padovan

Bluetooth: Replaced kzalloc and memcpy with kmemdup

Replaced calls to kzalloc followed by memcpy with a single call to kmemdup.
Signed-off-by: default avatarAlexandru Gheorghiu <gheorghiuandru@gmail.com>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent 12033caf
...@@ -397,13 +397,12 @@ static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb, ...@@ -397,13 +397,12 @@ static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
if (ctrl) { if (ctrl) {
u8 *assoc; u8 *assoc;
assoc = kzalloc(assoc_len, GFP_KERNEL); assoc = kmemdup(rsp->amp_assoc, assoc_len, GFP_KERNEL);
if (!assoc) { if (!assoc) {
amp_ctrl_put(ctrl); amp_ctrl_put(ctrl);
return -ENOMEM; return -ENOMEM;
} }
memcpy(assoc, rsp->amp_assoc, assoc_len);
ctrl->assoc = assoc; ctrl->assoc = assoc;
ctrl->assoc_len = assoc_len; ctrl->assoc_len = assoc_len;
ctrl->assoc_rem_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, ...@@ -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); size_t assoc_len = le16_to_cpu(hdr->len) - sizeof(*req);
u8 *assoc; u8 *assoc;
assoc = kzalloc(assoc_len, GFP_KERNEL); assoc = kmemdup(req->amp_assoc, assoc_len, GFP_KERNEL);
if (!assoc) { if (!assoc) {
amp_ctrl_put(ctrl); amp_ctrl_put(ctrl);
return -ENOMEM; return -ENOMEM;
} }
memcpy(assoc, req->amp_assoc, assoc_len);
ctrl->assoc = assoc; ctrl->assoc = assoc;
ctrl->assoc_len = assoc_len; ctrl->assoc_len = assoc_len;
ctrl->assoc_rem_len = assoc_len; ctrl->assoc_rem_len = assoc_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment