Bluetooth: Avoid deadlock in management ops code
Fixes a deadlock issue due to spinlock being acquired first in the process context and followed by a second acquisition in the interrupt context CRs-fixed: 319052 Change-Id: If17be9fa6f020dd1abd248f8999c2614251fc509 Signed-off-by: Subramanian Srinivasan <subrsrin@codeaurora.org>
This commit is contained in:
@@ -581,8 +581,11 @@ int hci_dev_open(__u16 dev)
|
|||||||
set_bit(HCI_UP, &hdev->flags);
|
set_bit(HCI_UP, &hdev->flags);
|
||||||
hci_notify(hdev, HCI_DEV_UP);
|
hci_notify(hdev, HCI_DEV_UP);
|
||||||
if (!test_bit(HCI_SETUP, &hdev->flags) &&
|
if (!test_bit(HCI_SETUP, &hdev->flags) &&
|
||||||
hdev->dev_type == HCI_BREDR)
|
hdev->dev_type == HCI_BREDR) {
|
||||||
|
hci_dev_lock_bh(hdev);
|
||||||
mgmt_powered(hdev->id, 1);
|
mgmt_powered(hdev->id, 1);
|
||||||
|
hci_dev_unlock_bh(hdev);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Init failed, cleanup */
|
/* Init failed, cleanup */
|
||||||
tasklet_kill(&hdev->rx_task);
|
tasklet_kill(&hdev->rx_task);
|
||||||
@@ -668,8 +671,11 @@ static int hci_dev_do_close(struct hci_dev *hdev)
|
|||||||
* and no tasks are scheduled. */
|
* and no tasks are scheduled. */
|
||||||
hdev->close(hdev);
|
hdev->close(hdev);
|
||||||
|
|
||||||
if (hdev->dev_type == HCI_BREDR)
|
if (hdev->dev_type == HCI_BREDR) {
|
||||||
|
hci_dev_lock_bh(hdev);
|
||||||
mgmt_powered(hdev->id, 0);
|
mgmt_powered(hdev->id, 0);
|
||||||
|
hci_dev_unlock_bh(hdev);
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear only non-persistent flags */
|
/* Clear only non-persistent flags */
|
||||||
if (test_bit(HCI_MGMT, &hdev->flags))
|
if (test_bit(HCI_MGMT, &hdev->flags))
|
||||||
@@ -1547,8 +1553,11 @@ int hci_unregister_dev(struct hci_dev *hdev)
|
|||||||
|
|
||||||
if (!test_bit(HCI_INIT, &hdev->flags) &&
|
if (!test_bit(HCI_INIT, &hdev->flags) &&
|
||||||
!test_bit(HCI_SETUP, &hdev->flags) &&
|
!test_bit(HCI_SETUP, &hdev->flags) &&
|
||||||
hdev->dev_type == HCI_BREDR)
|
hdev->dev_type == HCI_BREDR) {
|
||||||
|
hci_dev_lock_bh(hdev);
|
||||||
mgmt_index_removed(hdev->id);
|
mgmt_index_removed(hdev->id);
|
||||||
|
hci_dev_unlock_bh(hdev);
|
||||||
|
}
|
||||||
|
|
||||||
if (!IS_ERR(hdev->tfm))
|
if (!IS_ERR(hdev->tfm))
|
||||||
crypto_free_blkcipher(hdev->tfm);
|
crypto_free_blkcipher(hdev->tfm);
|
||||||
|
|||||||
@@ -223,12 +223,13 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME);
|
sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME);
|
||||||
if (!sent)
|
if (!sent)
|
||||||
return;
|
return;
|
||||||
|
hci_dev_lock(hdev);
|
||||||
if (!status)
|
if (!status)
|
||||||
memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH);
|
memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH);
|
||||||
|
|
||||||
if (test_bit(HCI_MGMT, &hdev->flags))
|
if (test_bit(HCI_MGMT, &hdev->flags))
|
||||||
mgmt_set_local_name_complete(hdev->id, sent, status);
|
mgmt_set_local_name_complete(hdev->id, sent, status);
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb)
|
static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb)
|
||||||
@@ -303,6 +304,7 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
if (!status) {
|
if (!status) {
|
||||||
__u8 param = *((__u8 *) sent);
|
__u8 param = *((__u8 *) sent);
|
||||||
int old_pscan, old_iscan;
|
int old_pscan, old_iscan;
|
||||||
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags);
|
old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags);
|
||||||
old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags);
|
old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags);
|
||||||
@@ -320,6 +322,7 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
mgmt_connectable(hdev->id, 1);
|
mgmt_connectable(hdev->id, 1);
|
||||||
} else if (old_pscan)
|
} else if (old_pscan)
|
||||||
mgmt_connectable(hdev->id, 0);
|
mgmt_connectable(hdev->id, 0);
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status);
|
hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status);
|
||||||
@@ -859,20 +862,23 @@ static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
struct hci_conn *conn;
|
struct hci_conn *conn;
|
||||||
|
|
||||||
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
||||||
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
if (test_bit(HCI_MGMT, &hdev->flags))
|
if (test_bit(HCI_MGMT, &hdev->flags))
|
||||||
mgmt_pin_code_reply_complete(hdev->id, &rp->bdaddr, rp->status);
|
mgmt_pin_code_reply_complete(hdev->id, &rp->bdaddr, rp->status);
|
||||||
|
|
||||||
if (rp->status != 0)
|
if (rp->status != 0)
|
||||||
return;
|
goto unlock;
|
||||||
|
|
||||||
cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY);
|
cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY);
|
||||||
if (!cp)
|
if (!cp)
|
||||||
return;
|
goto unlock;
|
||||||
|
|
||||||
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
|
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
|
||||||
if (conn)
|
if (conn)
|
||||||
conn->pin_length = cp->pin_len;
|
conn->pin_length = cp->pin_len;
|
||||||
|
unlock:
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
|
static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
|
||||||
@@ -880,10 +886,12 @@ static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
struct hci_rp_pin_code_neg_reply *rp = (void *) skb->data;
|
struct hci_rp_pin_code_neg_reply *rp = (void *) skb->data;
|
||||||
|
|
||||||
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
||||||
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
if (test_bit(HCI_MGMT, &hdev->flags))
|
if (test_bit(HCI_MGMT, &hdev->flags))
|
||||||
mgmt_pin_code_neg_reply_complete(hdev->id, &rp->bdaddr,
|
mgmt_pin_code_neg_reply_complete(hdev->id, &rp->bdaddr,
|
||||||
rp->status);
|
rp->status);
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
}
|
}
|
||||||
static void hci_cc_le_read_buffer_size(struct hci_dev *hdev,
|
static void hci_cc_le_read_buffer_size(struct hci_dev *hdev,
|
||||||
struct sk_buff *skb)
|
struct sk_buff *skb)
|
||||||
@@ -910,10 +918,12 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
|
struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
|
||||||
|
|
||||||
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
||||||
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
if (test_bit(HCI_MGMT, &hdev->flags))
|
if (test_bit(HCI_MGMT, &hdev->flags))
|
||||||
mgmt_user_confirm_reply_complete(hdev->id, &rp->bdaddr,
|
mgmt_user_confirm_reply_complete(hdev->id, &rp->bdaddr,
|
||||||
rp->status);
|
rp->status);
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev,
|
static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev,
|
||||||
@@ -922,10 +932,12 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev,
|
|||||||
struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
|
struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
|
||||||
|
|
||||||
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
||||||
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
if (test_bit(HCI_MGMT, &hdev->flags))
|
if (test_bit(HCI_MGMT, &hdev->flags))
|
||||||
mgmt_user_confirm_neg_reply_complete(hdev->id, &rp->bdaddr,
|
mgmt_user_confirm_neg_reply_complete(hdev->id, &rp->bdaddr,
|
||||||
rp->status);
|
rp->status);
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev,
|
static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev,
|
||||||
@@ -934,9 +946,11 @@ static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev,
|
|||||||
struct hci_rp_read_local_oob_data *rp = (void *) skb->data;
|
struct hci_rp_read_local_oob_data *rp = (void *) skb->data;
|
||||||
|
|
||||||
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
BT_DBG("%s status 0x%x", hdev->name, rp->status);
|
||||||
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
mgmt_read_local_oob_data_reply_complete(hdev->id, rp->hash,
|
mgmt_read_local_oob_data_reply_complete(hdev->id, rp->hash,
|
||||||
rp->randomizer, rp->status);
|
rp->randomizer, rp->status);
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_cc_le_ltk_reply(struct hci_dev *hdev, struct sk_buff *skb)
|
static void hci_cc_le_ltk_reply(struct hci_dev *hdev, struct sk_buff *skb)
|
||||||
@@ -995,8 +1009,10 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
|
|||||||
hci_conn_check_pending(hdev);
|
hci_conn_check_pending(hdev);
|
||||||
} else {
|
} else {
|
||||||
set_bit(HCI_INQUIRY, &hdev->flags);
|
set_bit(HCI_INQUIRY, &hdev->flags);
|
||||||
|
hci_dev_lock(hdev);
|
||||||
if (test_bit(HCI_MGMT, &hdev->flags))
|
if (test_bit(HCI_MGMT, &hdev->flags))
|
||||||
mgmt_inquiry_started(hdev->id);
|
mgmt_inquiry_started(hdev->id);
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1506,9 +1522,11 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
|
|||||||
clear_bit(HCI_INQUIRY, &hdev->flags);
|
clear_bit(HCI_INQUIRY, &hdev->flags);
|
||||||
|
|
||||||
hci_req_complete(hdev, HCI_OP_INQUIRY, status);
|
hci_req_complete(hdev, HCI_OP_INQUIRY, status);
|
||||||
|
hci_dev_lock(hdev);
|
||||||
|
|
||||||
if (test_bit(HCI_MGMT, &hdev->flags))
|
if (test_bit(HCI_MGMT, &hdev->flags))
|
||||||
mgmt_inquiry_complete_evt(hdev->id, status);
|
mgmt_inquiry_complete_evt(hdev->id, status);
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
|
|
||||||
if (!lmp_le_capable(hdev))
|
if (!lmp_le_capable(hdev))
|
||||||
hci_conn_check_pending(hdev);
|
hci_conn_check_pending(hdev);
|
||||||
@@ -1709,7 +1727,9 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
|
|||||||
BT_DBG("%s status %d", hdev->name, ev->status);
|
BT_DBG("%s status %d", hdev->name, ev->status);
|
||||||
|
|
||||||
if (ev->status) {
|
if (ev->status) {
|
||||||
|
hci_dev_lock(hdev);
|
||||||
mgmt_disconnect_failed(hdev->id);
|
mgmt_disconnect_failed(hdev->id);
|
||||||
|
hci_dev_unlock(hdev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ static int read_controller_info(struct sock *sk, u16 index)
|
|||||||
|
|
||||||
hci_del_off_timer(hdev);
|
hci_del_off_timer(hdev);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
set_bit(HCI_MGMT, &hdev->flags);
|
set_bit(HCI_MGMT, &hdev->flags);
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ static int read_controller_info(struct sock *sk, u16 index)
|
|||||||
|
|
||||||
memcpy(rp.name, hdev->dev_name, sizeof(hdev->dev_name));
|
memcpy(rp.name, hdev->dev_name, sizeof(hdev->dev_name));
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return cmd_complete(sk, index, MGMT_OP_READ_INFO, &rp, sizeof(rp));
|
return cmd_complete(sk, index, MGMT_OP_READ_INFO, &rp, sizeof(rp));
|
||||||
@@ -377,7 +377,7 @@ static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_SET_POWERED, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_SET_POWERED, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
up = test_bit(HCI_UP, &hdev->flags);
|
up = test_bit(HCI_UP, &hdev->flags);
|
||||||
if ((cp->val && up) || (!cp->val && !up)) {
|
if ((cp->val && up) || (!cp->val && !up)) {
|
||||||
@@ -404,7 +404,7 @@ static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -467,7 +467,7 @@ static int set_limited_discoverable(struct sock *sk, u16 index,
|
|||||||
return cmd_status(sk, index, MGMT_OP_SET_LIMIT_DISCOVERABLE,
|
return cmd_status(sk, index, MGMT_OP_SET_LIMIT_DISCOVERABLE,
|
||||||
ENODEV);
|
ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_UP, &hdev->flags)) {
|
if (!test_bit(HCI_UP, &hdev->flags)) {
|
||||||
err = cmd_status(sk, index, MGMT_OP_SET_LIMIT_DISCOVERABLE,
|
err = cmd_status(sk, index, MGMT_OP_SET_LIMIT_DISCOVERABLE,
|
||||||
@@ -521,7 +521,7 @@ static int set_limited_discoverable(struct sock *sk, u16 index,
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -547,7 +547,7 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_UP, &hdev->flags)) {
|
if (!test_bit(HCI_UP, &hdev->flags)) {
|
||||||
err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, ENETDOWN);
|
err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, ENETDOWN);
|
||||||
@@ -582,7 +582,7 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -608,7 +608,7 @@ static int set_connectable(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_UP, &hdev->flags)) {
|
if (!test_bit(HCI_UP, &hdev->flags)) {
|
||||||
err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, ENETDOWN);
|
err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, ENETDOWN);
|
||||||
@@ -642,7 +642,7 @@ static int set_connectable(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -703,7 +703,7 @@ static int set_pairable(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_SET_PAIRABLE, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_SET_PAIRABLE, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (cp->val)
|
if (cp->val)
|
||||||
set_bit(HCI_PAIRABLE, &hdev->flags);
|
set_bit(HCI_PAIRABLE, &hdev->flags);
|
||||||
@@ -719,7 +719,7 @@ static int set_pairable(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
err = mgmt_event(MGMT_EV_PAIRABLE, index, &ev, sizeof(ev), sk);
|
err = mgmt_event(MGMT_EV_PAIRABLE, index, &ev, sizeof(ev), sk);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -887,7 +887,7 @@ static int add_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_ADD_UUID, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_ADD_UUID, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
uuid = kmalloc(sizeof(*uuid), GFP_ATOMIC);
|
uuid = kmalloc(sizeof(*uuid), GFP_ATOMIC);
|
||||||
if (!uuid) {
|
if (!uuid) {
|
||||||
@@ -911,7 +911,7 @@ static int add_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
err = cmd_complete(sk, index, MGMT_OP_ADD_UUID, NULL, 0);
|
err = cmd_complete(sk, index, MGMT_OP_ADD_UUID, NULL, 0);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -936,7 +936,7 @@ static int remove_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_REMOVE_UUID, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_REMOVE_UUID, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (memcmp(cp->uuid, bt_uuid_any, 16) == 0) {
|
if (memcmp(cp->uuid, bt_uuid_any, 16) == 0) {
|
||||||
err = hci_uuids_clear(hdev);
|
err = hci_uuids_clear(hdev);
|
||||||
@@ -971,7 +971,7 @@ static int remove_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, NULL, 0);
|
err = cmd_complete(sk, index, MGMT_OP_REMOVE_UUID, NULL, 0);
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -995,7 +995,7 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
hdev->major_class &= ~MGMT_MAJOR_CLASS_MASK;
|
hdev->major_class &= ~MGMT_MAJOR_CLASS_MASK;
|
||||||
hdev->major_class |= cp->major & MGMT_MAJOR_CLASS_MASK;
|
hdev->major_class |= cp->major & MGMT_MAJOR_CLASS_MASK;
|
||||||
@@ -1006,7 +1006,7 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (err == 0)
|
if (err == 0)
|
||||||
err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, NULL, 0);
|
err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, NULL, 0);
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1028,7 +1028,7 @@ static int set_service_cache(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
BT_DBG("hci%u enable %d", index, cp->enable);
|
BT_DBG("hci%u enable %d", index, cp->enable);
|
||||||
|
|
||||||
@@ -1046,7 +1046,7 @@ static int set_service_cache(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
err = cmd_complete(sk, index, MGMT_OP_SET_SERVICE_CACHE, NULL,
|
err = cmd_complete(sk, index, MGMT_OP_SET_SERVICE_CACHE, NULL,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1080,7 +1080,7 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
BT_DBG("hci%u debug_keys %u key_count %u", index, cp->debug_keys,
|
BT_DBG("hci%u debug_keys %u key_count %u", index, cp->debug_keys,
|
||||||
key_count);
|
key_count);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
hci_link_keys_clear(hdev);
|
hci_link_keys_clear(hdev);
|
||||||
|
|
||||||
@@ -1118,7 +1118,7 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
|
|
||||||
err = cmd_complete(sk, index, MGMT_OP_LOAD_KEYS, NULL, 0);
|
err = cmd_complete(sk, index, MGMT_OP_LOAD_KEYS, NULL, 0);
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1140,7 +1140,7 @@ static int remove_key(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_REMOVE_KEY, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_REMOVE_KEY, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
err = hci_remove_link_key(hdev, &cp->bdaddr);
|
err = hci_remove_link_key(hdev, &cp->bdaddr);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
@@ -1163,7 +1163,7 @@ static int remove_key(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1189,7 +1189,7 @@ static int disconnect(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_DISCONNECT, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_DISCONNECT, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_UP, &hdev->flags)) {
|
if (!test_bit(HCI_UP, &hdev->flags)) {
|
||||||
err = cmd_status(sk, index, MGMT_OP_DISCONNECT, ENETDOWN);
|
err = cmd_status(sk, index, MGMT_OP_DISCONNECT, ENETDOWN);
|
||||||
@@ -1225,7 +1225,7 @@ static int disconnect(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1246,7 +1246,7 @@ static int get_connections(struct sock *sk, u16 index)
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_GET_CONNECTIONS, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_GET_CONNECTIONS, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
list_for_each(p, &hdev->conn_hash.list) {
|
list_for_each(p, &hdev->conn_hash.list) {
|
||||||
@@ -1277,7 +1277,7 @@ static int get_connections(struct sock *sk, u16 index)
|
|||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
kfree(rp);
|
kfree(rp);
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -1302,7 +1302,7 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_UP, &hdev->flags)) {
|
if (!test_bit(HCI_UP, &hdev->flags)) {
|
||||||
err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, ENETDOWN);
|
err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, ENETDOWN);
|
||||||
@@ -1324,7 +1324,7 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1409,7 +1409,7 @@ static int pin_code_neg_reply(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
return cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY,
|
return cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY,
|
||||||
ENODEV);
|
ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_UP, &hdev->flags)) {
|
if (!test_bit(HCI_UP, &hdev->flags)) {
|
||||||
err = cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY,
|
err = cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY,
|
||||||
@@ -1430,7 +1430,7 @@ static int pin_code_neg_reply(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1453,14 +1453,14 @@ static int set_io_capability(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_SET_IO_CAPABILITY, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_SET_IO_CAPABILITY, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
hdev->io_capability = cp->io_capability;
|
hdev->io_capability = cp->io_capability;
|
||||||
|
|
||||||
BT_DBG("%s IO capability set to 0x%02x", hdev->name,
|
BT_DBG("%s IO capability set to 0x%02x", hdev->name,
|
||||||
hdev->io_capability);
|
hdev->io_capability);
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return cmd_complete(sk, index, MGMT_OP_SET_IO_CAPABILITY, NULL, 0);
|
return cmd_complete(sk, index, MGMT_OP_SET_IO_CAPABILITY, NULL, 0);
|
||||||
@@ -1600,7 +1600,7 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_PAIR_DEVICE, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_PAIR_DEVICE, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
BT_DBG("SSP Cap is %d", cp->ssp_cap);
|
BT_DBG("SSP Cap is %d", cp->ssp_cap);
|
||||||
io_cap = cp->io_cap;
|
io_cap = cp->io_cap;
|
||||||
@@ -1655,7 +1655,7 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
|
|||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1685,7 +1685,7 @@ static int user_confirm_reply(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, mgmt_op, ENODEV);
|
return cmd_status(sk, index, mgmt_op, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_UP, &hdev->flags)) {
|
if (!test_bit(HCI_UP, &hdev->flags)) {
|
||||||
err = cmd_status(sk, index, mgmt_op, ENETDOWN);
|
err = cmd_status(sk, index, mgmt_op, ENETDOWN);
|
||||||
@@ -1711,7 +1711,7 @@ static int user_confirm_reply(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1735,7 +1735,7 @@ static int resolve_name(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_RESOLVE_NAME, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_RESOLVE_NAME, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
cmd = mgmt_pending_add(sk, MGMT_OP_RESOLVE_NAME, index, data, len);
|
cmd = mgmt_pending_add(sk, MGMT_OP_RESOLVE_NAME, index, data, len);
|
||||||
if (!cmd) {
|
if (!cmd) {
|
||||||
@@ -1751,7 +1751,7 @@ static int resolve_name(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1776,7 +1776,7 @@ static int set_connection_params(struct sock *sk, u16 index,
|
|||||||
return cmd_status(sk, index, MGMT_OP_SET_CONNECTION_PARAMS,
|
return cmd_status(sk, index, MGMT_OP_SET_CONNECTION_PARAMS,
|
||||||
ENODEV);
|
ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->bdaddr);
|
conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->bdaddr);
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
@@ -1793,7 +1793,7 @@ static int set_connection_params(struct sock *sk, u16 index,
|
|||||||
err = cmd_status(sk, index, MGMT_OP_SET_CONNECTION_PARAMS, 0);
|
err = cmd_status(sk, index, MGMT_OP_SET_CONNECTION_PARAMS, 0);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1817,7 +1817,7 @@ static int set_local_name(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_SET_LOCAL_NAME, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_SET_LOCAL_NAME, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, index, data, len);
|
cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, index, data, len);
|
||||||
if (!cmd) {
|
if (!cmd) {
|
||||||
@@ -1832,7 +1832,7 @@ static int set_local_name(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -1883,9 +1883,6 @@ void mgmt_inquiry_complete_evt(u16 index, u8 status)
|
|||||||
|
|
||||||
hdev = hci_dev_get(index);
|
hdev = hci_dev_get(index);
|
||||||
|
|
||||||
if (hdev)
|
|
||||||
hci_dev_lock(hdev);
|
|
||||||
|
|
||||||
if (!hdev || !lmp_le_capable(hdev)) {
|
if (!hdev || !lmp_le_capable(hdev)) {
|
||||||
struct mgmt_mode cp = {0};
|
struct mgmt_mode cp = {0};
|
||||||
|
|
||||||
@@ -1919,7 +1916,6 @@ void mgmt_inquiry_complete_evt(u16 index, u8 status)
|
|||||||
discovery_terminated, NULL);
|
discovery_terminated, NULL);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
hci_dev_unlock(hdev);
|
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1935,7 +1931,7 @@ static void disco_to(unsigned long data)
|
|||||||
hdev = hci_dev_get(ilp->index);
|
hdev = hci_dev_get(ilp->index);
|
||||||
|
|
||||||
if (hdev) {
|
if (hdev) {
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, ilp->index);
|
cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, ilp->index);
|
||||||
|
|
||||||
@@ -1960,7 +1956,7 @@ static void disco_to(unsigned long data)
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1977,7 +1973,7 @@ static void disco_le_to(unsigned long data)
|
|||||||
hdev = hci_dev_get(ilp->index);
|
hdev = hci_dev_get(ilp->index);
|
||||||
|
|
||||||
if (hdev) {
|
if (hdev) {
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, ilp->index);
|
cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, ilp->index);
|
||||||
|
|
||||||
@@ -1996,7 +1992,7 @@ static void disco_le_to(unsigned long data)
|
|||||||
} else
|
} else
|
||||||
ilp->mode = SCAN_IDLE;
|
ilp->mode = SCAN_IDLE;
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2014,7 +2010,7 @@ static int start_discovery(struct sock *sk, u16 index)
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_START_DISCOVERY, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_START_DISCOVERY, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, index, NULL, 0);
|
cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, index, NULL, 0);
|
||||||
if (!cmd) {
|
if (!cmd) {
|
||||||
@@ -2069,7 +2065,7 @@ static int start_discovery(struct sock *sk, u16 index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -2090,7 +2086,7 @@ static int stop_discovery(struct sock *sk, u16 index)
|
|||||||
if (!hdev)
|
if (!hdev)
|
||||||
return cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, ENODEV);
|
return cmd_status(sk, index, MGMT_OP_STOP_DISCOVERY, ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (lmp_le_capable(hdev)) {
|
if (lmp_le_capable(hdev)) {
|
||||||
cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, index);
|
cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, index);
|
||||||
@@ -2124,7 +2120,7 @@ static int stop_discovery(struct sock *sk, u16 index)
|
|||||||
mgmt_event(MGMT_EV_DISCOVERING, index, &mode_cp, sizeof(mode_cp), NULL);
|
mgmt_event(MGMT_EV_DISCOVERING, index, &mode_cp, sizeof(mode_cp), NULL);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
@@ -2146,7 +2142,7 @@ static int read_local_oob_data(struct sock *sk, u16 index)
|
|||||||
return cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
|
return cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
|
||||||
ENODEV);
|
ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_UP, &hdev->flags)) {
|
if (!test_bit(HCI_UP, &hdev->flags)) {
|
||||||
err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
|
err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
|
||||||
@@ -2176,7 +2172,7 @@ static int read_local_oob_data(struct sock *sk, u16 index)
|
|||||||
mgmt_pending_remove(cmd);
|
mgmt_pending_remove(cmd);
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -2200,7 +2196,7 @@ static int add_remote_oob_data(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
return cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA,
|
return cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA,
|
||||||
ENODEV);
|
ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
err = hci_add_remote_oob_data(hdev, &cp->bdaddr, cp->hash,
|
err = hci_add_remote_oob_data(hdev, &cp->bdaddr, cp->hash,
|
||||||
cp->randomizer);
|
cp->randomizer);
|
||||||
@@ -2210,7 +2206,7 @@ static int add_remote_oob_data(struct sock *sk, u16 index, unsigned char *data,
|
|||||||
err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, NULL,
|
err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, NULL,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -2234,7 +2230,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index,
|
|||||||
return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
|
return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
|
||||||
ENODEV);
|
ENODEV);
|
||||||
|
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
err = hci_remove_remote_oob_data(hdev, &cp->bdaddr);
|
err = hci_remove_remote_oob_data(hdev, &cp->bdaddr);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
@@ -2244,7 +2240,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index,
|
|||||||
err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
|
err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
|
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -2765,9 +2761,7 @@ int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status)
|
|||||||
|
|
||||||
hdev = hci_dev_get(index);
|
hdev = hci_dev_get(index);
|
||||||
if (hdev) {
|
if (hdev) {
|
||||||
hci_dev_lock_bh(hdev);
|
|
||||||
update_eir(hdev);
|
update_eir(hdev);
|
||||||
hci_dev_unlock_bh(hdev);
|
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user