Skip to content

Commit

Permalink
Bluetooth: hci_conn: Use kmemdup() to replace kzalloc + memcpy
Browse files Browse the repository at this point in the history
Use kmemdup rather than duplicating its implementation.

./net/bluetooth/hci_conn.c:1880:7-14: WARNING opportunity for kmemdup.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5597
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jiapeng Chong authored and kuba-moo committed Jun 29, 2023
1 parent fa01eba commit 5b6d345
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1862,12 +1862,10 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos)
if (qos->ucast.cis == BT_ISO_QOS_CIS_UNSET || !data.pdu.cp.num_cis)
return false;

pdu = kzalloc(sizeof(*pdu), GFP_KERNEL);
pdu = kmemdup(&data.pdu, sizeof(*pdu), GFP_KERNEL);
if (!pdu)
return false;

memcpy(pdu, &data.pdu, sizeof(*pdu));

if (hci_cmd_sync_queue(hdev, set_cig_params_sync, pdu,
set_cig_params_complete) < 0) {
kfree(pdu);
Expand Down

0 comments on commit 5b6d345

Please sign in to comment.