diff mbox series

Bluetooth: hci_event: Fix Invalid wait context

Message ID 20230111012254.3724082-1-luiz.dentz@gmail.com
State New
Headers show
Series Bluetooth: hci_event: Fix Invalid wait context | expand

Commit Message

Luiz Augusto von Dentz Jan. 11, 2023, 1:22 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This fixes the following trace caused by attempting to lock
cmd_sync_work_lock while holding the rcu_read_lock:

kworker/u3:2/212 is trying to lock:
ffff888002600910 (&hdev->cmd_sync_work_lock){+.+.}-{3:3}, at:
hci_cmd_sync_queue+0xad/0x140
other info that might help us debug this:
context-{4:4}
4 locks held by kworker/u3:2/212:
 #0: ffff8880028c6530 ((wq_completion)hci0#2){+.+.}-{0:0}, at:
 process_one_work+0x4dc/0x9a0
 #1: ffff888001aafde0 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0},
 at: process_one_work+0x4dc/0x9a0
 #2: ffff888002600070 (&hdev->lock){+.+.}-{3:3}, at:
 hci_cc_le_set_cig_params+0x64/0x4f0
 #3: ffffffffa5994b00 (rcu_read_lock){....}-{1:2}, at:
 hci_cc_le_set_cig_params+0x2f9/0x4f0

Fixes: 26afbd826ee3 ("Bluetooth: Add initial implementation of CIS connections")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/hci_event.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

bluez.test.bot@gmail.com Jan. 11, 2023, 2:41 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=710751

---Test result---

Test Summary:
CheckPatch                    PASS      0.79 seconds
GitLint                       PASS      0.23 seconds
SubjectPrefix                 PASS      0.06 seconds
BuildKernel                   PASS      38.57 seconds
CheckAllWarning               PASS      43.05 seconds
CheckSparse                   WARNING   48.98 seconds
CheckSmatch                   WARNING   128.74 seconds
BuildKernel32                 PASS      37.90 seconds
TestRunnerSetup               PASS      540.85 seconds
TestRunner_l2cap-tester       PASS      18.79 seconds
TestRunner_iso-tester         PASS      20.54 seconds
TestRunner_bnep-tester        PASS      6.58 seconds
TestRunner_mgmt-tester        PASS      128.52 seconds
TestRunner_rfcomm-tester      PASS      10.52 seconds
TestRunner_sco-tester         PASS      10.03 seconds
TestRunner_ioctl-tester       PASS      12.19 seconds
TestRunner_mesh-tester        PASS      8.28 seconds
TestRunner_smp-tester         PASS      9.58 seconds
TestRunner_userchan-tester    PASS      7.12 seconds
IncrementalBuild              PASS      35.88 seconds

Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):


---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org Jan. 11, 2023, 8:10 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 Tue, 10 Jan 2023 17:22:53 -0800 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This fixes the following trace caused by attempting to lock
> cmd_sync_work_lock while holding the rcu_read_lock:
> 
> kworker/u3:2/212 is trying to lock:
> ffff888002600910 (&hdev->cmd_sync_work_lock){+.+.}-{3:3}, at:
> hci_cmd_sync_queue+0xad/0x140
> other info that might help us debug this:
> context-{4:4}
> 4 locks held by kworker/u3:2/212:
>  #0: ffff8880028c6530 ((wq_completion)hci0#2){+.+.}-{0:0}, at:
>  process_one_work+0x4dc/0x9a0
>  #1: ffff888001aafde0 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0},
>  at: process_one_work+0x4dc/0x9a0
>  #2: ffff888002600070 (&hdev->lock){+.+.}-{3:3}, at:
>  hci_cc_le_set_cig_params+0x64/0x4f0
>  #3: ffffffffa5994b00 (rcu_read_lock){....}-{1:2}, at:
>  hci_cc_le_set_cig_params+0x2f9/0x4f0
> 
> [...]

Here is the summary with links:
  - Bluetooth: hci_event: Fix Invalid wait context
    https://git.kernel.org/bluetooth/bluetooth-next/c/fd18e1680ee2

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 0594af4e37ca..ad92a4be5851 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3848,8 +3848,11 @@  static u8 hci_cc_le_set_cig_params(struct hci_dev *hdev, void *data,
 			   conn->handle, conn->link);
 
 		/* Create CIS if LE is already connected */
-		if (conn->link && conn->link->state == BT_CONNECTED)
+		if (conn->link && conn->link->state == BT_CONNECTED) {
+			rcu_read_unlock();
 			hci_le_create_cis(conn->link);
+			rcu_read_lock();
+		}
 
 		if (i == rp->num_handles)
 			break;