Skip to content

Commit 87be7b1

Browse files
committed
Bluetooth: Fix usage of __hci_cmd_sync_status
__hci_cmd_sync_status shall only be used if hci_req_sync_lock is _not_ required which is not the case of hci_dev_cmd so it needs to use hci_cmd_sync_status which uses hci_req_sync_lock internally. Fixes: f1a8f40 ("Bluetooth: L2CAP: Fix deadlock") Reported-by: Pauli Virtanen <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 473a89b commit 87be7b1

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

net/bluetooth/hci_core.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,8 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
718718

719719
switch (cmd) {
720720
case HCISETAUTH:
721-
err = __hci_cmd_sync_status(hdev, HCI_OP_WRITE_AUTH_ENABLE,
722-
1, &dr.dev_opt, HCI_CMD_TIMEOUT);
721+
err = hci_cmd_sync_status(hdev, HCI_OP_WRITE_AUTH_ENABLE,
722+
1, &dr.dev_opt, HCI_CMD_TIMEOUT);
723723
break;
724724

725725
case HCISETENCRYPT:
@@ -730,23 +730,21 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
730730

731731
if (!test_bit(HCI_AUTH, &hdev->flags)) {
732732
/* Auth must be enabled first */
733-
err = __hci_cmd_sync_status(hdev,
734-
HCI_OP_WRITE_AUTH_ENABLE,
735-
1, &dr.dev_opt,
736-
HCI_CMD_TIMEOUT);
733+
err = hci_cmd_sync_status(hdev,
734+
HCI_OP_WRITE_AUTH_ENABLE,
735+
1, &dr.dev_opt,
736+
HCI_CMD_TIMEOUT);
737737
if (err)
738738
break;
739739
}
740740

741-
err = __hci_cmd_sync_status(hdev, HCI_OP_WRITE_ENCRYPT_MODE,
742-
1, &dr.dev_opt,
743-
HCI_CMD_TIMEOUT);
741+
err = hci_cmd_sync_status(hdev, HCI_OP_WRITE_ENCRYPT_MODE,
742+
1, &dr.dev_opt, HCI_CMD_TIMEOUT);
744743
break;
745744

746745
case HCISETSCAN:
747-
err = __hci_cmd_sync_status(hdev, HCI_OP_WRITE_SCAN_ENABLE,
748-
1, &dr.dev_opt,
749-
HCI_CMD_TIMEOUT);
746+
err = hci_cmd_sync_status(hdev, HCI_OP_WRITE_SCAN_ENABLE,
747+
1, &dr.dev_opt, HCI_CMD_TIMEOUT);
750748

751749
/* Ensure that the connectable and discoverable states
752750
* get correctly modified as this was a non-mgmt change.
@@ -758,9 +756,8 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
758756
case HCISETLINKPOL:
759757
policy = cpu_to_le16(dr.dev_opt);
760758

761-
err = __hci_cmd_sync_status(hdev, HCI_OP_WRITE_DEF_LINK_POLICY,
762-
2, &policy,
763-
HCI_CMD_TIMEOUT);
759+
err = hci_cmd_sync_status(hdev, HCI_OP_WRITE_DEF_LINK_POLICY,
760+
2, &policy, HCI_CMD_TIMEOUT);
764761
break;
765762

766763
case HCISETLINKMODE:

0 commit comments

Comments
 (0)