Skip to content

Commit

Permalink
Bluetooth: mgmt: Fix address type while loading Long Term Key
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hemant Gupta authored and Gustavo Padovan committed May 9, 2012
1 parent 0c01bc4 commit 4596fde
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 4596fde

Please sign in to comment.