diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-09-08 20:09:49 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-09-08 21:12:15 -0400 |
commit | e1e930f591bfd9604c3077f0af5c390f4f890259 (patch) | |
tree | 6a336f7ddb09a2e53150907656207088afb24b0e /net/bluetooth | |
parent | c68b7f127d5f517c214e8bcf231d0188f6776d2a (diff) |
Bluetooth: Fix mgmt pairing failure when authentication fails
Whether through HCI with BR/EDR or SMP with LE when authentication fails
we should also notify any pending Pair Device mgmt command. This patch
updates the mgmt_auth_failed function to take the actual hci_conn object
and makes sure that any pending pairing command is notified and cleaned
up appropriately.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_event.c | 6 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 19 | ||||
-rw-r--r-- | net/bluetooth/smp.c | 3 |
3 files changed, 16 insertions, 12 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index e6a496ae0318..3a8381ab992f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -2320,8 +2320,7 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2320 | conn->sec_level = conn->pending_sec_level; | 2320 | conn->sec_level = conn->pending_sec_level; |
2321 | } | 2321 | } |
2322 | } else { | 2322 | } else { |
2323 | mgmt_auth_failed(hdev, &conn->dst, conn->type, conn->dst_type, | 2323 | mgmt_auth_failed(conn, ev->status); |
2324 | ev->status); | ||
2325 | } | 2324 | } |
2326 | 2325 | ||
2327 | clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); | 2326 | clear_bit(HCI_CONN_AUTH_PEND, &conn->flags); |
@@ -3900,8 +3899,7 @@ static void hci_simple_pair_complete_evt(struct hci_dev *hdev, | |||
3900 | * event gets always produced as initiator and is also mapped to | 3899 | * event gets always produced as initiator and is also mapped to |
3901 | * the mgmt_auth_failed event */ | 3900 | * the mgmt_auth_failed event */ |
3902 | if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) | 3901 | if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status) |
3903 | mgmt_auth_failed(hdev, &conn->dst, conn->type, conn->dst_type, | 3902 | mgmt_auth_failed(conn, ev->status); |
3904 | ev->status); | ||
3905 | 3903 | ||
3906 | hci_conn_drop(conn); | 3904 | hci_conn_drop(conn); |
3907 | 3905 | ||
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index ab9521ae3c63..efb71b022ab6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -6485,16 +6485,23 @@ int mgmt_user_passkey_notify(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
6485 | return mgmt_event(MGMT_EV_PASSKEY_NOTIFY, hdev, &ev, sizeof(ev), NULL); | 6485 | return mgmt_event(MGMT_EV_PASSKEY_NOTIFY, hdev, &ev, sizeof(ev), NULL); |
6486 | } | 6486 | } |
6487 | 6487 | ||
6488 | void mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | 6488 | void mgmt_auth_failed(struct hci_conn *conn, u8 hci_status) |
6489 | u8 addr_type, u8 status) | ||
6490 | { | 6489 | { |
6491 | struct mgmt_ev_auth_failed ev; | 6490 | struct mgmt_ev_auth_failed ev; |
6491 | struct pending_cmd *cmd; | ||
6492 | u8 status = mgmt_status(hci_status); | ||
6492 | 6493 | ||
6493 | bacpy(&ev.addr.bdaddr, bdaddr); | 6494 | bacpy(&ev.addr.bdaddr, &conn->dst); |
6494 | ev.addr.type = link_to_bdaddr(link_type, addr_type); | 6495 | ev.addr.type = link_to_bdaddr(conn->type, conn->dst_type); |
6495 | ev.status = mgmt_status(status); | 6496 | ev.status = status; |
6496 | 6497 | ||
6497 | mgmt_event(MGMT_EV_AUTH_FAILED, hdev, &ev, sizeof(ev), NULL); | 6498 | cmd = find_pairing(conn); |
6499 | |||
6500 | mgmt_event(MGMT_EV_AUTH_FAILED, conn->hdev, &ev, sizeof(ev), | ||
6501 | cmd ? cmd->sk : NULL); | ||
6502 | |||
6503 | if (cmd) | ||
6504 | pairing_complete(cmd, status); | ||
6498 | } | 6505 | } |
6499 | 6506 | ||
6500 | void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) | 6507 | void mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status) |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 560f78a9f960..25c9040e0b12 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -420,8 +420,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason) | |||
420 | &reason); | 420 | &reason); |
421 | 421 | ||
422 | clear_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags); | 422 | clear_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags); |
423 | mgmt_auth_failed(hcon->hdev, &hcon->dst, hcon->type, hcon->dst_type, | 423 | mgmt_auth_failed(hcon, HCI_ERROR_AUTH_FAILURE); |
424 | HCI_ERROR_AUTH_FAILURE); | ||
425 | 424 | ||
426 | if (chan->data) | 425 | if (chan->data) |
427 | smp_chan_destroy(conn); | 426 | smp_chan_destroy(conn); |