diff mbox series

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

Message ID 20230625084513.6319-1-jiapeng.chong@linux.alibaba.com (mailing list archive)
State Accepted
Commit f1a9a7cc825f5ed4e6cc0e84884d926bb9be5c47
Headers show
Series Bluetooth: hci_conn: Use kmemdup() to replace kzalloc + memcpy | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/SubjectPrefix success Gitlint PASS
tedd_an/BuildKernel success BuildKernel PASS
tedd_an/CheckAllWarning success CheckAllWarning PASS
tedd_an/CheckSparse success CheckSparse PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/BuildKernel32 success BuildKernel32 PASS
tedd_an/TestRunnerSetup success TestRunnerSetup PASS
tedd_an/TestRunner_l2cap-tester success TestRunner PASS
tedd_an/TestRunner_iso-tester fail TestRunner_iso-tester: Total: 80, Passed: 76 (95.0%), Failed: 4, Not Run: 0
tedd_an/TestRunner_bnep-tester success TestRunner PASS
tedd_an/TestRunner_mgmt-tester success TestRunner PASS
tedd_an/TestRunner_rfcomm-tester success TestRunner PASS
tedd_an/TestRunner_sco-tester success TestRunner PASS
tedd_an/TestRunner_ioctl-tester success TestRunner PASS
tedd_an/TestRunner_mesh-tester success TestRunner PASS
tedd_an/TestRunner_smp-tester success TestRunner PASS
tedd_an/TestRunner_userchan-tester success TestRunner PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Jiapeng Chong June 25, 2023, 8:45 a.m. UTC
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>
---
 net/bluetooth/hci_conn.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

bluez.test.bot@gmail.com June 25, 2023, 9:39 a.m. UTC | #1
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
patchwork-bot+bluetooth@kernel.org June 26, 2023, 8:42 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

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.
> 
> 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>
> 
> [...]

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!
diff mbox series

Patch

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 62a7ccfdfe63..47e7aa4d63a9 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -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);