fixup! Bluetooth: hci_core: Fix triggering cmd_timer for HCI_OP_NOP
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v2 1/1 fixup! Bluetooth: hci_core: Fix triggering cmd_timer for HCI_OP_NOP
From: Luiz Augusto von Dentz <[email protected]>
--- net/bluetooth/hci_core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
net/bluetooth/hci_core.c +11 -9
@@ -4121,7 +4121,7 @@ static void hci_rx_work(struct work_struct *work) } } -static void hci_send_cmd_sync (struct hci_dev *hdev,struct sk_buff *skb) +static int hci_send_cmd_sync (struct hci_dev *hdev,struct sk_buff *skb) {int err;
@@ -4133,16 +4133,19 @@ static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)if (!hdev->sent_cmd) {skb_queue_head (&hdev->cmd_q, skb);queue_work (hdev->workqueue, &hdev->cmd_work); -return ; +return -EINVAL ; }if (hci_skb_opcode (skb) !=HCI_OP_NOP ) { err =hci_send_frame (hdev, skb);if (err <0 ) {hci_cmd_sync_cancel_sync (hdev, -err); -return ; +return err; }atomic_dec (&hdev->cmd_cnt); + }else { + err = -ENODATA ; +kfree_skb (skb); } if (hdev->req_status == HCI_REQ_PEND &&
@@ -4150,12 +4153,15 @@ static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)kfree_skb (hdev->req_skb); hdev->req_skb =skb_clone (hdev->sent_cmd,GFP_KERNEL ); } + +return err; }static void hci_cmd_work (struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev, cmd_work);struct sk_buff *skb; +int err;BT_DBG ("%s cmd_cnt %d cmd queued %d" , hdev->name,atomic_read (&hdev->cmd_cnt),skb_queue_len (&hdev->cmd_q));
@@ -4166,12 +4172,8 @@ static void hci_cmd_work(struct work_struct *work)if (!skb)return ; -hci_send_cmd_sync (hdev, skb); - -/* Don't trigger cmd_timer in case of HCI_OP_NOP since there is -* no command pending. -*/ -if (hci_skb_opcode (skb) ==HCI_OP_NOP ) + err =hci_send_cmd_sync (hdev, skb); +if (err)return ;rcu_read_lock ();
Signature · 1 line
2.51.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=1024529
---Test result---
Test Summary:
CheckPatch PENDING 0.41 seconds GitLint PENDING 0.24 seconds SubjectPrefix PASS 0.09 seconds BuildKernel PASS 25.18 seconds CheckAllWarning PASS 28.16 seconds CheckSparse WARNING 33.86 seconds BuildKernel32 PASS 25.17 seconds TestRunnerSetup PASS 546.30 seconds TestRunner_l2cap-tester PASS 23.68 seconds TestRunner_iso-tester PASS 76.63 seconds TestRunner_bnep-tester PASS 6.05 seconds TestRunner_mgmt-tester FAIL 111.67 seconds TestRunner_rfcomm-tester PASS 9.09 seconds TestRunner_sco-tester PASS 14.16 seconds TestRunner_ioctl-tester PASS 9.73 seconds TestRunner_mesh-tester FAIL 11.43 seconds TestRunner_smp-tester PASS 8.32 seconds TestRunner_userchan-tester PASS 6.54 seconds IncrementalBuild PENDING 0.80 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:net/bluetooth/hci_core.c:85:9: warning: context imbalance in '__hci_dev_get' - different lock contexts for basic blocknet/bluetooth/hci_core.c: note: in included file (through include/linux/notifier.h, include/linux/memory_hotplug.h, include/linux/mmzone.h, include/linux/gfp.h, include/linux/xarray.h, include/linux/radix-tree.h, ...):
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 487 (98.6%), Failed: 3, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.092 seconds LL Privacy - Add Device 3 (AL is full) Failed 0.194 seconds LL Privacy - Set Flags 3 (2 Devices to RL) Failed 0.172 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.102 seconds Mesh - Send cancel - 2 Timed out 1.999 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerHi Pauli,
Quoted 34 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Fixes 486a25d25a4b3 ("Bluetooth: hci_core: Fix triggering cmd_timer for HCI_OP_NOP")Reported-by [email protected]Signed-off-by Pauli Virtanen <[email protected]>Signed-off-by Luiz Augusto von Dentz <[email protected]>--- net/bluetooth/hci_core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)net/bluetooth/hci_core.c +2
-2@@ -4121,7 +4121,7 @@ static void hci_rx_work(struct work_struct *work) } } -static void hci_send_cmd_sync (struct hci_dev *hdev,struct sk_buff *skb) +static int hci_send_cmd_sync (struct hci_dev *hdev,struct sk_buff *skb) {int err;@@ -4133,16 +4133,19 @@ static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)if (!hdev->sent_cmd) {skb_queue_head (&hdev->cmd_q, skb);queue_work (hdev->workqueue, &hdev->cmd_work); -return ; +return -EINVAL ; }if (hci_skb_opcode (skb) !=HCI_OP_NOP ) {
net/bluetooth/hci_core.c static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb) · line 4148
Quoted 10 lines
net/bluetooth/hci_core.c +4
-1err =hci_send_frame (hdev, skb);if (err <0 ) {hci_cmd_sync_cancel_sync (hdev, -err); -return ; +return err; }atomic_dec (&hdev->cmd_cnt); + }else { + err = -ENODATA ; +kfree_skb (skb);
Does this address your concern about the skb not being consumed/leaking?
Quoted 37 lines
net/bluetooth/hci_core.c +5
-7} if (hdev->req_status == HCI_REQ_PEND &&@@ -4150,12 +4153,15 @@ static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)kfree_skb (hdev->req_skb); hdev->req_skb =skb_clone (hdev->sent_cmd,GFP_KERNEL ); } + +return err; }static void hci_cmd_work (struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev, cmd_work);struct sk_buff *skb; +int err;BT_DBG ("%s cmd_cnt %d cmd queued %d" , hdev->name,atomic_read (&hdev->cmd_cnt),skb_queue_len (&hdev->cmd_q));@@ -4166,12 +4172,8 @@ static void hci_cmd_work(struct work_struct *work)if (!skb)return ; -hci_send_cmd_sync (hdev, skb); - -/* Don't trigger cmd_timer in case of HCI_OP_NOP since there is -* no command pending. -*/ -if (hci_skb_opcode (skb) ==HCI_OP_NOP ) + err =hci_send_cmd_sync (hdev, skb); +if (err)return ;rcu_read_lock (); --2.51.1
Signature · 1 line
Luiz Augusto von Dentz
Hi,
18. marraskuuta 2025 14.16.42 UTC Luiz Augusto von Dentz <[email protected]> kirjoitti:
Quoted 37 lines
Hi Pauli,
Quoted 33 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Fixes 486a25d25a4b3 ("Bluetooth: hci_core: Fix triggering cmd_timer for HCI_OP_NOP")Reported-by [email protected]Signed-off-by Pauli Virtanen <[email protected]>Signed-off-by Luiz Augusto von Dentz <[email protected]>--- net/bluetooth/hci_core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)net/bluetooth/hci_core.c +2
-2@@ -4121,7 +4121,7 @@ static void hci_rx_work(struct work_struct *work) } } -static void hci_send_cmd_sync (struct hci_dev *hdev,struct sk_buff *skb) +static int hci_send_cmd_sync (struct hci_dev *hdev,struct sk_buff *skb) {int err;@@ -4133,16 +4133,19 @@ static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)if (!hdev->sent_cmd) {skb_queue_head (&hdev->cmd_q, skb);queue_work (hdev->workqueue, &hdev->cmd_work); -return ; +return -EINVAL ; }
Quoted 13 lines
net/bluetooth/hci_core.c static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb) · line 4148
Quoted 11 lines
net/bluetooth/hci_core.c +4
-1if (hci_skb_opcode (skb) !=HCI_OP_NOP ) { err =hci_send_frame (hdev, skb);if (err <0 ) {hci_cmd_sync_cancel_sync (hdev, -err); -return ; +return err; }atomic_dec (&hdev->cmd_cnt); + }else { + err = -ENODATA ; +kfree_skb (skb);Does this address your concern about the skb not being consumed/leaking?
Yes, I think now the original skb gets freed in all paths.
Quoted 40 lines
Quoted 38 lines
net/bluetooth/hci_core.c +5
-7} if (hdev->req_status == HCI_REQ_PEND &&@@ -4150,12 +4153,15 @@ static void hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)kfree_skb (hdev->req_skb); hdev->req_skb =skb_clone (hdev->sent_cmd,GFP_KERNEL ); } + +return err; }static void hci_cmd_work (struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev, cmd_work);struct sk_buff *skb; +int err;BT_DBG ("%s cmd_cnt %d cmd queued %d" , hdev->name,atomic_read (&hdev->cmd_cnt),skb_queue_len (&hdev->cmd_q));@@ -4166,12 +4172,8 @@ static void hci_cmd_work(struct work_struct *work)if (!skb)return ; -hci_send_cmd_sync (hdev, skb); - -/* Don't trigger cmd_timer in case of HCI_OP_NOP since there is -* no command pending. -*/ -if (hci_skb_opcode (skb) ==HCI_OP_NOP ) + err =hci_send_cmd_sync (hdev, skb); +if (err)return ;rcu_read_lock (); --2.51.1