Skip to contentSkip to conversation

Bluetooth: hci_conn: Use kmemdup() to replace kzalloc + memcpy

PATCH Applied Jiapeng Chong 3 participants 3 messages Jun 25, 2023 – Jun 26, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: hci_conn: Use kmemdup() to replace kzalloc + memcpy

Use kmemdup rather than duplicating its implementation.

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

---
 net/bluetooth/hci_conn.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/bluetooth/hci_conn.c +1 -3
index 62a7ccfdfe63..47e7aa4d63a9 100644
@@ -1877,12 +1877,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);
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=760042

---Test result---

Test Summary:

CheckPatch                    PASS      0.83 seconds
GitLint                       PASS      0.38 seconds
SubjectPrefix                 PASS      0.13 seconds
BuildKernel                   PASS      43.44 seconds
CheckAllWarning               PASS      48.03 seconds
CheckSparse                   PASS      53.73 seconds
CheckSmatch                   PASS      146.70 seconds
BuildKernel32                 PASS      42.48 seconds
TestRunnerSetup               PASS      604.44 seconds
TestRunner_l2cap-tester       PASS      21.55 seconds
TestRunner_iso-tester         FAIL      31.74 seconds
TestRunner_bnep-tester        PASS      7.74 seconds
TestRunner_mgmt-tester        PASS      162.79 seconds
TestRunner_rfcomm-tester      PASS      12.28 seconds
TestRunner_sco-tester         PASS      11.08 seconds
TestRunner_ioctl-tester       PASS      13.28 seconds
TestRunner_mesh-tester        PASS      9.83 seconds
TestRunner_smp-tester         PASS      10.66 seconds
TestRunner_userchan-tester    PASS      8.00 seconds
IncrementalBuild              PASS      40.10 seconds

Details
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner Output:
Total: 80, Passed: 76 (95.0%), Failed: 4, Not Run: 0

Failed Test Cases

ISO Receive - Success                                Failed       0.272 seconds
ISO Receive Timestamped - Success                    Failed       0.256 seconds
ISO Defer Receive - Success                          Failed       0.260 seconds
ISO 48_2_1 Defer Receive - Success                   Failed       0.264 seconds

---
Regards,
Linux Bluetooth

#2 lore raw
In reply to Jiapeng Chong
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 9 lines · On Sun, 25 Jun 2023 16:45:13 +0800 you wrote:

Use kmemdup rather than duplicating its implementation.

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

[...]

Here is the summary with links:
- Bluetooth: hci_conn: Use kmemdup() to replace kzalloc + memcpy

    https://git.kernel.org/bluetooth/bluetooth-next/c/f1a9a7cc825f

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html