summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorJohan Hedberg2011-04-28 20:29:03 +0200
committerGustavo F. Padovan2011-04-28 21:14:43 +0200
commit4df378a10e31698df1679f3329301d773a654b61 (patch)
tree033d9f8267801fd657339fd0299c96979556930f /net/bluetooth/hci_core.c
parentBluetooth: Remove old_key_type from mgmt_ev_new_key (diff)
downloadkernel-qcow2-linux-4df378a10e31698df1679f3329301d773a654b61.tar.gz
kernel-qcow2-linux-4df378a10e31698df1679f3329301d773a654b61.tar.xz
kernel-qcow2-linux-4df378a10e31698df1679f3329301d773a654b61.zip
Bluetooth: Add store_hint parameter to mgmt_new_key
Even for keys that shouldn't be stored some use cases require the knowledge of a new key having been created so that the conclusion of a successful pairing can be made. Therefore, always send the mgmt_new_key event but add a store_hint parameter to it to indicate to user space whether the key should be stored or not. Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 60260cae3a04..b6bda3fac10e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1062,7 +1062,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len)
{
struct link_key *key, *old_key;
- u8 old_key_type;
+ u8 old_key_type, persistent;
old_key = hci_find_link_key(hdev, bdaddr);
if (old_key) {
@@ -1089,12 +1089,6 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
conn->key_type = type;
}
- if (new_key && !hci_persistent_key(hdev, conn, type, old_key_type)) {
- list_del(&key->list);
- kfree(key);
- return 0;
- }
-
bacpy(&key->bdaddr, bdaddr);
memcpy(key->val, val, 16);
key->pin_len = pin_len;
@@ -1104,8 +1098,17 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
else
key->type = type;
- if (new_key)
- mgmt_new_key(hdev->id, key);
+ if (!new_key)
+ return 0;
+
+ persistent = hci_persistent_key(hdev, conn, type, old_key_type);
+
+ mgmt_new_key(hdev->id, key, persistent);
+
+ if (!persistent) {
+ list_del(&key->list);
+ kfree(key);
+ }
return 0;
}