summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHemant Gupta <hemant.gupta@stericsson.com>2012-04-16 14:57:40 +0530
committerGustavo Padovan <gustavo@padovan.org>2012-05-09 01:40:33 -0300
commit4596fde5401679f062336c6dbad8d9e4043858c2 (patch)
treea408855aa0479f8af5b5862573d7175d69c0a800
parent0c01bc486a6f5f397732f808ecbcd63665c605d8 (diff)
downloadlinux-stable-4596fde5401679f062336c6dbad8d9e4043858c2.tar.gz
linux-stable-4596fde5401679f062336c6dbad8d9e4043858c2.tar.bz2
linux-stable-4596fde5401679f062336c6dbad8d9e4043858c2.zip
Bluetooth: mgmt: Fix address type while loading Long Term Key
This patch fixes the address type while loading long term keys when BT is switched on. Without this fix pairing is reinitated even though LTK exists for remote device because of mismatch of address type. Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--net/bluetooth/mgmt.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b50e2ee2595c..7d37c88e4bf5 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1644,6 +1644,18 @@ static u8 link_to_mgmt(u8 link_type, u8 addr_type)
}
}
+static u8 mgmt_to_le(u8 mgmt_type)
+{
+ switch (mgmt_type) {
+ case MGMT_ADDR_LE_PUBLIC:
+ return ADDR_LE_DEV_PUBLIC;
+
+ default:
+ /* Fallback to LE Random address type */
+ return ADDR_LE_DEV_RANDOM;
+ }
+}
+
static int get_connections(struct sock *sk, struct hci_dev *hdev, void *data,
u16 data_len)
{
@@ -2652,7 +2664,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
else
type = HCI_SMP_LTK_SLAVE;
- hci_add_ltk(hdev, &key->addr.bdaddr, key->addr.type,
+ hci_add_ltk(hdev, &key->addr.bdaddr,
+ mgmt_to_le(key->addr.type),
type, 0, key->authenticated, key->val,
key->enc_size, key->ediv, key->rand);
}