Skip to content

Commit 308a3a8

Browse files
pvVudentz
authored andcommitted
Bluetooth: hci_core: fix list_for_each_entry_rcu usage
Releasing + re-acquiring RCU lock inside list_for_each_entry_rcu() loop body is not correct. Fix by taking the update-side hdev->lock instead. Fixes: c7eaf80 ("Bluetooth: Fix hci_link_tx_to RCU lock usage") Signed-off-by: Pauli Virtanen <[email protected]> Reviewed-by: Paul Menzel <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 3cae906 commit 308a3a8

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

net/bluetooth/hci_core.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3417,23 +3417,18 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type)
34173417

34183418
bt_dev_err(hdev, "link tx timeout");
34193419

3420-
rcu_read_lock();
3420+
hci_dev_lock(hdev);
34213421

34223422
/* Kill stalled connections */
3423-
list_for_each_entry_rcu(c, &h->list, list) {
3423+
list_for_each_entry(c, &h->list, list) {
34243424
if (c->type == type && c->sent) {
34253425
bt_dev_err(hdev, "killing stalled connection %pMR",
34263426
&c->dst);
3427-
/* hci_disconnect might sleep, so, we have to release
3428-
* the RCU read lock before calling it.
3429-
*/
3430-
rcu_read_unlock();
34313427
hci_disconnect(c, HCI_ERROR_REMOTE_USER_TERM);
3432-
rcu_read_lock();
34333428
}
34343429
}
34353430

3436-
rcu_read_unlock();
3431+
hci_dev_unlock(hdev);
34373432
}
34383433

34393434
static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type,

0 commit comments

Comments
 (0)