aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-03-19 11:00:49 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-03-19 16:56:30 -0400
commit4e7b2030c452e5d885d36d4f44ef33d6ceb9759a (patch)
tree6ef6b9ecd8dfeb8a9d6532f0a466712219b444b1 /net/bluetooth/mgmt.c
parent01ad34d267475ac3387d7ab803a2225b392dae91 (diff)
Bluetooth: Fix Pair Device response parameters for pairing failure
It is possible that pairing fails after we've already received remote identity information. One example of such a situation is when re-encryption using the LTK fails. In this case the hci_conn object has already been updated with the identity address but user space does not yet know about it (since we didn't notify it of the new IRK yet). To ensure user space doesn't get a Pair Device command response with an unknown address always use the same address in the response as was used for the original command. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 75df93679276..96670f581bb0 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2762,11 +2762,23 @@ static struct pending_cmd *find_pairing(struct hci_conn *conn)
2762 2762
2763static void pairing_complete(struct pending_cmd *cmd, u8 status) 2763static void pairing_complete(struct pending_cmd *cmd, u8 status)
2764{ 2764{
2765 const struct mgmt_cp_pair_device *cp = cmd->param;
2765 struct mgmt_rp_pair_device rp; 2766 struct mgmt_rp_pair_device rp;
2766 struct hci_conn *conn = cmd->user_data; 2767 struct hci_conn *conn = cmd->user_data;
2767 2768
2768 bacpy(&rp.addr.bdaddr, &conn->dst); 2769 /* If we had a pairing failure we might have already received
2769 rp.addr.type = link_to_bdaddr(conn->type, conn->dst_type); 2770 * the remote Identity Address Information and updated the
2771 * hci_conn variables with it, however we would not yet have
2772 * notified user space of the resolved identity. Therefore, use
2773 * the address given in the Pair Device command in case the
2774 * pairing failed.
2775 */
2776 if (status) {
2777 memcpy(&rp.addr, &cp->addr, sizeof(rp.addr));
2778 } else {
2779 bacpy(&rp.addr.bdaddr, &conn->dst);
2780 rp.addr.type = link_to_bdaddr(conn->type, conn->dst_type);
2781 }
2770 2782
2771 cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, status, 2783 cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, status,
2772 &rp, sizeof(rp)); 2784 &rp, sizeof(rp));