Commit a463e9c5 authored by John W. Linville's avatar John W. Linville

Merge branch 'for-upstream' of...

Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
parents 67e2c388 9845904f
...@@ -87,6 +87,7 @@ static const struct usb_device_id ath3k_table[] = { ...@@ -87,6 +87,7 @@ static const struct usb_device_id ath3k_table[] = {
{ USB_DEVICE(0x04CA, 0x3007) }, { USB_DEVICE(0x04CA, 0x3007) },
{ USB_DEVICE(0x04CA, 0x3008) }, { USB_DEVICE(0x04CA, 0x3008) },
{ USB_DEVICE(0x04CA, 0x300b) }, { USB_DEVICE(0x04CA, 0x300b) },
{ USB_DEVICE(0x04CA, 0x3010) },
{ USB_DEVICE(0x0930, 0x0219) }, { USB_DEVICE(0x0930, 0x0219) },
{ USB_DEVICE(0x0930, 0x0220) }, { USB_DEVICE(0x0930, 0x0220) },
{ USB_DEVICE(0x0930, 0x0227) }, { USB_DEVICE(0x0930, 0x0227) },
...@@ -140,6 +141,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = { ...@@ -140,6 +141,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = {
{ USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x04ca, 0x3010), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0930, 0x0220), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0930, 0x0220), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0930, 0x0227), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0930, 0x0227), .driver_info = BTUSB_ATH3012 },
......
...@@ -167,6 +167,7 @@ static const struct usb_device_id blacklist_table[] = { ...@@ -167,6 +167,7 @@ static const struct usb_device_id blacklist_table[] = {
{ USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x04ca, 0x3010), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0930, 0x0220), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0930, 0x0220), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0930, 0x0227), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0930, 0x0227), .driver_info = BTUSB_ATH3012 },
......
...@@ -661,7 +661,7 @@ static void hci_req_add_le_create_conn(struct hci_request *req, ...@@ -661,7 +661,7 @@ static void hci_req_add_le_create_conn(struct hci_request *req,
memset(&cp, 0, sizeof(cp)); memset(&cp, 0, sizeof(cp));
/* Update random address, but set require_privacy to false so /* Update random address, but set require_privacy to false so
* that we never connect with an unresolvable address. * that we never connect with an non-resolvable address.
*/ */
if (hci_update_random_address(req, false, &own_addr_type)) if (hci_update_random_address(req, false, &own_addr_type))
return; return;
......
...@@ -1373,8 +1373,6 @@ static void hci_init1_req(struct hci_request *req, unsigned long opt) ...@@ -1373,8 +1373,6 @@ static void hci_init1_req(struct hci_request *req, unsigned long opt)
static void bredr_setup(struct hci_request *req) static void bredr_setup(struct hci_request *req)
{ {
struct hci_dev *hdev = req->hdev;
__le16 param; __le16 param;
__u8 flt_type; __u8 flt_type;
...@@ -1403,14 +1401,6 @@ static void bredr_setup(struct hci_request *req) ...@@ -1403,14 +1401,6 @@ static void bredr_setup(struct hci_request *req)
/* Connection accept timeout ~20 secs */ /* Connection accept timeout ~20 secs */
param = cpu_to_le16(0x7d00); param = cpu_to_le16(0x7d00);
hci_req_add(req, HCI_OP_WRITE_CA_TIMEOUT, 2, &param); hci_req_add(req, HCI_OP_WRITE_CA_TIMEOUT, 2, &param);
/* AVM Berlin (31), aka "BlueFRITZ!", reports version 1.2,
* but it does not support page scan related HCI commands.
*/
if (hdev->manufacturer != 31 && hdev->hci_ver > BLUETOOTH_VER_1_1) {
hci_req_add(req, HCI_OP_READ_PAGE_SCAN_ACTIVITY, 0, NULL);
hci_req_add(req, HCI_OP_READ_PAGE_SCAN_TYPE, 0, NULL);
}
} }
static void le_setup(struct hci_request *req) static void le_setup(struct hci_request *req)
...@@ -1718,6 +1708,16 @@ static void hci_init3_req(struct hci_request *req, unsigned long opt) ...@@ -1718,6 +1708,16 @@ static void hci_init3_req(struct hci_request *req, unsigned long opt)
if (hdev->commands[5] & 0x10) if (hdev->commands[5] & 0x10)
hci_setup_link_policy(req); hci_setup_link_policy(req);
if (hdev->commands[8] & 0x01)
hci_req_add(req, HCI_OP_READ_PAGE_SCAN_ACTIVITY, 0, NULL);
/* Some older Broadcom based Bluetooth 1.2 controllers do not
* support the Read Page Scan Type command. Check support for
* this command in the bit mask of supported commands.
*/
if (hdev->commands[13] & 0x01)
hci_req_add(req, HCI_OP_READ_PAGE_SCAN_TYPE, 0, NULL);
if (lmp_le_capable(hdev)) { if (lmp_le_capable(hdev)) {
u8 events[8]; u8 events[8];
...@@ -2634,6 +2634,12 @@ static int hci_dev_do_close(struct hci_dev *hdev) ...@@ -2634,6 +2634,12 @@ static int hci_dev_do_close(struct hci_dev *hdev)
drain_workqueue(hdev->workqueue); drain_workqueue(hdev->workqueue);
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
if (hdev->dev_type == HCI_BREDR)
mgmt_powered(hdev, 0);
}
hci_inquiry_cache_flush(hdev); hci_inquiry_cache_flush(hdev);
hci_pend_le_actions_clear(hdev); hci_pend_le_actions_clear(hdev);
hci_conn_hash_flush(hdev); hci_conn_hash_flush(hdev);
...@@ -2681,14 +2687,6 @@ static int hci_dev_do_close(struct hci_dev *hdev) ...@@ -2681,14 +2687,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
hdev->flags &= BIT(HCI_RAW); hdev->flags &= BIT(HCI_RAW);
hdev->dev_flags &= ~HCI_PERSISTENT_MASK; hdev->dev_flags &= ~HCI_PERSISTENT_MASK;
if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
if (hdev->dev_type == HCI_BREDR) {
hci_dev_lock(hdev);
mgmt_powered(hdev, 0);
hci_dev_unlock(hdev);
}
}
/* Controller radio is available but is currently powered down */ /* Controller radio is available but is currently powered down */
hdev->amp_status = AMP_STATUS_POWERED_DOWN; hdev->amp_status = AMP_STATUS_POWERED_DOWN;
...@@ -3083,7 +3081,9 @@ static void hci_power_on(struct work_struct *work) ...@@ -3083,7 +3081,9 @@ static void hci_power_on(struct work_struct *work)
err = hci_dev_do_open(hdev); err = hci_dev_do_open(hdev);
if (err < 0) { if (err < 0) {
hci_dev_lock(hdev);
mgmt_set_powered_failed(hdev, err); mgmt_set_powered_failed(hdev, err);
hci_dev_unlock(hdev);
return; return;
} }
...@@ -3959,17 +3959,29 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy, ...@@ -3959,17 +3959,29 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy,
} }
/* In case of required privacy without resolvable private address, /* In case of required privacy without resolvable private address,
* use an unresolvable private address. This is useful for active * use an non-resolvable private address. This is useful for active
* scanning and non-connectable advertising. * scanning and non-connectable advertising.
*/ */
if (require_privacy) { if (require_privacy) {
bdaddr_t urpa; bdaddr_t nrpa;
while (true) {
/* The non-resolvable private address is generated
* from random six bytes with the two most significant
* bits cleared.
*/
get_random_bytes(&nrpa, 6);
nrpa.b[5] &= 0x3f;
get_random_bytes(&urpa, 6); /* The non-resolvable private address shall not be
urpa.b[5] &= 0x3f; /* Clear two most significant bits */ * equal to the public address.
*/
if (bacmp(&hdev->bdaddr, &nrpa))
break;
}
*own_addr_type = ADDR_LE_DEV_RANDOM; *own_addr_type = ADDR_LE_DEV_RANDOM;
set_random_addr(req, &urpa); set_random_addr(req, &nrpa);
return 0; return 0;
} }
...@@ -5625,7 +5637,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req) ...@@ -5625,7 +5637,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req)
u8 filter_policy; u8 filter_policy;
/* Set require_privacy to false since no SCAN_REQ are send /* Set require_privacy to false since no SCAN_REQ are send
* during passive scanning. Not using an unresolvable address * during passive scanning. Not using an non-resolvable address
* here is important so that peer devices using direct * here is important so that peer devices using direct
* advertising with our address will be correctly reported * advertising with our address will be correctly reported
* by the controller. * by the controller.
......
...@@ -257,6 +257,8 @@ static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -257,6 +257,8 @@ static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb)
if (!sent) if (!sent)
return; return;
hci_dev_lock(hdev);
if (!status) { if (!status) {
__u8 param = *((__u8 *) sent); __u8 param = *((__u8 *) sent);
...@@ -268,6 +270,8 @@ static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -268,6 +270,8 @@ static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb)
if (test_bit(HCI_MGMT, &hdev->dev_flags)) if (test_bit(HCI_MGMT, &hdev->dev_flags))
mgmt_auth_enable_complete(hdev, status); mgmt_auth_enable_complete(hdev, status);
hci_dev_unlock(hdev);
} }
static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb) static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb)
...@@ -443,6 +447,8 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -443,6 +447,8 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
if (!sent) if (!sent)
return; return;
hci_dev_lock(hdev);
if (!status) { if (!status) {
if (sent->mode) if (sent->mode)
hdev->features[1][0] |= LMP_HOST_SSP; hdev->features[1][0] |= LMP_HOST_SSP;
...@@ -458,6 +464,8 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -458,6 +464,8 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
else else
clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags); clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags);
} }
hci_dev_unlock(hdev);
} }
static void hci_cc_write_sc_support(struct hci_dev *hdev, struct sk_buff *skb) static void hci_cc_write_sc_support(struct hci_dev *hdev, struct sk_buff *skb)
...@@ -471,6 +479,8 @@ static void hci_cc_write_sc_support(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -471,6 +479,8 @@ static void hci_cc_write_sc_support(struct hci_dev *hdev, struct sk_buff *skb)
if (!sent) if (!sent)
return; return;
hci_dev_lock(hdev);
if (!status) { if (!status) {
if (sent->support) if (sent->support)
hdev->features[1][0] |= LMP_HOST_SC; hdev->features[1][0] |= LMP_HOST_SC;
...@@ -486,6 +496,8 @@ static void hci_cc_write_sc_support(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -486,6 +496,8 @@ static void hci_cc_write_sc_support(struct hci_dev *hdev, struct sk_buff *skb)
else else
clear_bit(HCI_SC_ENABLED, &hdev->dev_flags); clear_bit(HCI_SC_ENABLED, &hdev->dev_flags);
} }
hci_dev_unlock(hdev);
} }
static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb) static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb)
...@@ -1135,6 +1147,8 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, ...@@ -1135,6 +1147,8 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
if (!cp) if (!cp)
return; return;
hci_dev_lock(hdev);
switch (cp->enable) { switch (cp->enable) {
case LE_SCAN_ENABLE: case LE_SCAN_ENABLE:
set_bit(HCI_LE_SCAN, &hdev->dev_flags); set_bit(HCI_LE_SCAN, &hdev->dev_flags);
...@@ -1184,6 +1198,8 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, ...@@ -1184,6 +1198,8 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
BT_ERR("Used reserved LE_Scan_Enable param %d", cp->enable); BT_ERR("Used reserved LE_Scan_Enable param %d", cp->enable);
break; break;
} }
hci_dev_unlock(hdev);
} }
static void hci_cc_le_read_white_list_size(struct hci_dev *hdev, static void hci_cc_le_read_white_list_size(struct hci_dev *hdev,
...@@ -1278,6 +1294,8 @@ static void hci_cc_write_le_host_supported(struct hci_dev *hdev, ...@@ -1278,6 +1294,8 @@ static void hci_cc_write_le_host_supported(struct hci_dev *hdev,
if (!sent) if (!sent)
return; return;
hci_dev_lock(hdev);
if (sent->le) { if (sent->le) {
hdev->features[1][0] |= LMP_HOST_LE; hdev->features[1][0] |= LMP_HOST_LE;
set_bit(HCI_LE_ENABLED, &hdev->dev_flags); set_bit(HCI_LE_ENABLED, &hdev->dev_flags);
...@@ -1291,6 +1309,8 @@ static void hci_cc_write_le_host_supported(struct hci_dev *hdev, ...@@ -1291,6 +1309,8 @@ static void hci_cc_write_le_host_supported(struct hci_dev *hdev,
hdev->features[1][0] |= LMP_HOST_LE_BREDR; hdev->features[1][0] |= LMP_HOST_LE_BREDR;
else else
hdev->features[1][0] &= ~LMP_HOST_LE_BREDR; hdev->features[1][0] &= ~LMP_HOST_LE_BREDR;
hci_dev_unlock(hdev);
} }
static void hci_cc_set_adv_param(struct hci_dev *hdev, struct sk_buff *skb) static void hci_cc_set_adv_param(struct hci_dev *hdev, struct sk_buff *skb)
......
...@@ -6966,8 +6966,9 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) ...@@ -6966,8 +6966,9 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon)
test_bit(HCI_HS_ENABLED, &hcon->hdev->dev_flags)) test_bit(HCI_HS_ENABLED, &hcon->hdev->dev_flags))
conn->local_fixed_chan |= L2CAP_FC_A2MP; conn->local_fixed_chan |= L2CAP_FC_A2MP;
if (bredr_sc_enabled(hcon->hdev) && if (test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags) &&
test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags)) (bredr_sc_enabled(hcon->hdev) ||
test_bit(HCI_FORCE_LESC, &hcon->hdev->dbg_flags)))
conn->local_fixed_chan |= L2CAP_FC_SMP_BREDR; conn->local_fixed_chan |= L2CAP_FC_SMP_BREDR;
mutex_init(&conn->ident_lock); mutex_init(&conn->ident_lock);
......
...@@ -2199,12 +2199,14 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status) ...@@ -2199,12 +2199,14 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status)
{ {
struct cmd_lookup match = { NULL, hdev }; struct cmd_lookup match = { NULL, hdev };
hci_dev_lock(hdev);
if (status) { if (status) {
u8 mgmt_err = mgmt_status(status); u8 mgmt_err = mgmt_status(status);
mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, cmd_status_rsp, mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, cmd_status_rsp,
&mgmt_err); &mgmt_err);
return; goto unlock;
} }
mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, settings_rsp, &match); mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, settings_rsp, &match);
...@@ -2222,17 +2224,16 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status) ...@@ -2222,17 +2224,16 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status)
if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
struct hci_request req; struct hci_request req;
hci_dev_lock(hdev);
hci_req_init(&req, hdev); hci_req_init(&req, hdev);
update_adv_data(&req); update_adv_data(&req);
update_scan_rsp_data(&req); update_scan_rsp_data(&req);
hci_req_run(&req, NULL); hci_req_run(&req, NULL);
hci_update_background_scan(hdev); hci_update_background_scan(hdev);
hci_dev_unlock(hdev);
} }
unlock:
hci_dev_unlock(hdev);
} }
static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
...@@ -3114,14 +3115,13 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status) ...@@ -3114,14 +3115,13 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status)
conn->disconn_cfm_cb = NULL; conn->disconn_cfm_cb = NULL;
hci_conn_drop(conn); hci_conn_drop(conn);
hci_conn_put(conn);
mgmt_pending_remove(cmd);
/* The device is paired so there is no need to remove /* The device is paired so there is no need to remove
* its connection parameters anymore. * its connection parameters anymore.
*/ */
clear_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags); clear_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags);
hci_conn_put(conn);
} }
void mgmt_smp_complete(struct hci_conn *conn, bool complete) void mgmt_smp_complete(struct hci_conn *conn, bool complete)
...@@ -3130,8 +3130,10 @@ void mgmt_smp_complete(struct hci_conn *conn, bool complete) ...@@ -3130,8 +3130,10 @@ void mgmt_smp_complete(struct hci_conn *conn, bool complete)
struct pending_cmd *cmd; struct pending_cmd *cmd;
cmd = find_pairing(conn); cmd = find_pairing(conn);
if (cmd) if (cmd) {
cmd->cmd_complete(cmd, status); cmd->cmd_complete(cmd, status);
mgmt_pending_remove(cmd);
}
} }
static void pairing_complete_cb(struct hci_conn *conn, u8 status) static void pairing_complete_cb(struct hci_conn *conn, u8 status)
...@@ -3141,10 +3143,13 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status) ...@@ -3141,10 +3143,13 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status)
BT_DBG("status %u", status); BT_DBG("status %u", status);
cmd = find_pairing(conn); cmd = find_pairing(conn);
if (!cmd) if (!cmd) {
BT_DBG("Unable to find a pending command"); BT_DBG("Unable to find a pending command");
else return;
cmd->cmd_complete(cmd, mgmt_status(status)); }
cmd->cmd_complete(cmd, mgmt_status(status));
mgmt_pending_remove(cmd);
} }
static void le_pairing_complete_cb(struct hci_conn *conn, u8 status) static void le_pairing_complete_cb(struct hci_conn *conn, u8 status)
...@@ -3157,10 +3162,13 @@ static void le_pairing_complete_cb(struct hci_conn *conn, u8 status) ...@@ -3157,10 +3162,13 @@ static void le_pairing_complete_cb(struct hci_conn *conn, u8 status)
return; return;
cmd = find_pairing(conn); cmd = find_pairing(conn);
if (!cmd) if (!cmd) {
BT_DBG("Unable to find a pending command"); BT_DBG("Unable to find a pending command");
else return;
cmd->cmd_complete(cmd, mgmt_status(status)); }
cmd->cmd_complete(cmd, mgmt_status(status));
mgmt_pending_remove(cmd);
} }
static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
...@@ -3274,8 +3282,10 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -3274,8 +3282,10 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
cmd->user_data = hci_conn_get(conn); cmd->user_data = hci_conn_get(conn);
if ((conn->state == BT_CONNECTED || conn->state == BT_CONFIG) && if ((conn->state == BT_CONNECTED || conn->state == BT_CONFIG) &&
hci_conn_security(conn, sec_level, auth_type, true)) hci_conn_security(conn, sec_level, auth_type, true)) {
pairing_complete(cmd, 0); cmd->cmd_complete(cmd, 0);
mgmt_pending_remove(cmd);
}
err = 0; err = 0;
...@@ -3317,7 +3327,8 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, void *data, ...@@ -3317,7 +3327,8 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
goto unlock; goto unlock;
} }
pairing_complete(cmd, MGMT_STATUS_CANCELLED); cmd->cmd_complete(cmd, MGMT_STATUS_CANCELLED);
mgmt_pending_remove(cmd);
err = cmd_complete(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, 0, err = cmd_complete(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, 0,
addr, sizeof(*addr)); addr, sizeof(*addr));
...@@ -3791,7 +3802,7 @@ static bool trigger_discovery(struct hci_request *req, u8 *status) ...@@ -3791,7 +3802,7 @@ static bool trigger_discovery(struct hci_request *req, u8 *status)
/* All active scans will be done with either a resolvable /* All active scans will be done with either a resolvable
* private address (when privacy feature has been enabled) * private address (when privacy feature has been enabled)
* or unresolvable private address. * or non-resolvable private address.
*/ */
err = hci_update_random_address(req, true, &own_addr_type); err = hci_update_random_address(req, true, &own_addr_type);
if (err < 0) { if (err < 0) {
...@@ -4279,12 +4290,14 @@ static void set_advertising_complete(struct hci_dev *hdev, u8 status) ...@@ -4279,12 +4290,14 @@ static void set_advertising_complete(struct hci_dev *hdev, u8 status)
{ {
struct cmd_lookup match = { NULL, hdev }; struct cmd_lookup match = { NULL, hdev };
hci_dev_lock(hdev);
if (status) { if (status) {
u8 mgmt_err = mgmt_status(status); u8 mgmt_err = mgmt_status(status);
mgmt_pending_foreach(MGMT_OP_SET_ADVERTISING, hdev, mgmt_pending_foreach(MGMT_OP_SET_ADVERTISING, hdev,
cmd_status_rsp, &mgmt_err); cmd_status_rsp, &mgmt_err);
return; goto unlock;
} }
if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) if (test_bit(HCI_LE_ADV, &hdev->dev_flags))
...@@ -4299,6 +4312,9 @@ static void set_advertising_complete(struct hci_dev *hdev, u8 status) ...@@ -4299,6 +4312,9 @@ static void set_advertising_complete(struct hci_dev *hdev, u8 status)
if (match.sk) if (match.sk)
sock_put(match.sk); sock_put(match.sk);
unlock:
hci_dev_unlock(hdev);
} }
static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data, static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data,
...@@ -6081,6 +6097,11 @@ static int powered_update_hci(struct hci_dev *hdev) ...@@ -6081,6 +6097,11 @@ static int powered_update_hci(struct hci_dev *hdev)
hci_req_add(&req, HCI_OP_WRITE_SSP_MODE, 1, &ssp); hci_req_add(&req, HCI_OP_WRITE_SSP_MODE, 1, &ssp);
} }
if (bredr_sc_enabled(hdev) && !lmp_host_sc_capable(hdev)) {
u8 sc = 0x01;
hci_req_add(&req, HCI_OP_WRITE_SC_SUPPORT, sizeof(sc), &sc);
}
if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags) && if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags) &&
lmp_bredr_capable(hdev)) { lmp_bredr_capable(hdev)) {
struct hci_cp_write_le_host_supported cp; struct hci_cp_write_le_host_supported cp;
...@@ -6130,8 +6151,7 @@ static int powered_update_hci(struct hci_dev *hdev) ...@@ -6130,8 +6151,7 @@ static int powered_update_hci(struct hci_dev *hdev)
int mgmt_powered(struct hci_dev *hdev, u8 powered) int mgmt_powered(struct hci_dev *hdev, u8 powered)
{ {
struct cmd_lookup match = { NULL, hdev }; struct cmd_lookup match = { NULL, hdev };
u8 status_not_powered = MGMT_STATUS_NOT_POWERED; u8 status, zero_cod[] = { 0, 0, 0 };
u8 zero_cod[] = { 0, 0, 0 };
int err; int err;
if (!test_bit(HCI_MGMT, &hdev->dev_flags)) if (!test_bit(HCI_MGMT, &hdev->dev_flags))
...@@ -6147,7 +6167,20 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) ...@@ -6147,7 +6167,20 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
} }
mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match); mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match);
mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &status_not_powered);
/* If the power off is because of hdev unregistration let
* use the appropriate INVALID_INDEX status. Otherwise use
* NOT_POWERED. We cover both scenarios here since later in
* mgmt_index_removed() any hci_conn callbacks will have already
* been triggered, potentially causing misleading DISCONNECTED
* status responses.
*/
if (test_bit(HCI_UNREGISTER, &hdev->dev_flags))
status = MGMT_STATUS_INVALID_INDEX;
else
status = MGMT_STATUS_NOT_POWERED;
mgmt_pending_foreach(0, hdev, cmd_complete_rsp, &status);
if (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0) if (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0)
mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev,
...@@ -6681,8 +6714,10 @@ void mgmt_auth_failed(struct hci_conn *conn, u8 hci_status) ...@@ -6681,8 +6714,10 @@ void mgmt_auth_failed(struct hci_conn *conn, u8 hci_status)
mgmt_event(MGMT_EV_AUTH_FAILED, conn->hdev, &ev, sizeof(ev), mgmt_event(MGMT_EV_AUTH_FAILED, conn->hdev, &ev, sizeof(ev),
cmd ? cmd->sk : NULL); cmd ? cmd->sk : NULL);
if (cmd) if (cmd) {
pairing_complete(cmd, status); cmd->cmd_complete(cmd, status);
mgmt_pending_remove(cmd);
}
} }
void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status)
......
...@@ -1673,7 +1673,8 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -1673,7 +1673,8 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
/* SMP over BR/EDR requires special treatment */ /* SMP over BR/EDR requires special treatment */
if (conn->hcon->type == ACL_LINK) { if (conn->hcon->type == ACL_LINK) {
/* We must have a BR/EDR SC link */ /* We must have a BR/EDR SC link */
if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags)) if (!test_bit(HCI_CONN_AES_CCM, &conn->hcon->flags) &&
!test_bit(HCI_FORCE_LESC, &hdev->dbg_flags))
return SMP_CROSS_TRANSP_NOT_ALLOWED; return SMP_CROSS_TRANSP_NOT_ALLOWED;
set_bit(SMP_FLAG_SC, &smp->flags); set_bit(SMP_FLAG_SC, &smp->flags);
...@@ -2927,7 +2928,7 @@ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid) ...@@ -2927,7 +2928,7 @@ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid)
tfm_aes = crypto_alloc_blkcipher("ecb(aes)", 0, 0); tfm_aes = crypto_alloc_blkcipher("ecb(aes)", 0, 0);
if (IS_ERR(tfm_aes)) { if (IS_ERR(tfm_aes)) {
BT_ERR("Unable to create crypto context"); BT_ERR("Unable to create crypto context");
return ERR_PTR(PTR_ERR(tfm_aes)); return ERR_CAST(tfm_aes);
} }
create_chan: create_chan:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment