diff options
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r-- | net/bluetooth/hci_core.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 92a857e3786d..edfd61addcec 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -1215,40 +1215,40 @@ struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
1215 | return NULL; | 1215 | return NULL; |
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | static int hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn, | 1218 | static bool hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn, |
1219 | u8 key_type, u8 old_key_type) | 1219 | u8 key_type, u8 old_key_type) |
1220 | { | 1220 | { |
1221 | /* Legacy key */ | 1221 | /* Legacy key */ |
1222 | if (key_type < 0x03) | 1222 | if (key_type < 0x03) |
1223 | return 1; | 1223 | return true; |
1224 | 1224 | ||
1225 | /* Debug keys are insecure so don't store them persistently */ | 1225 | /* Debug keys are insecure so don't store them persistently */ |
1226 | if (key_type == HCI_LK_DEBUG_COMBINATION) | 1226 | if (key_type == HCI_LK_DEBUG_COMBINATION) |
1227 | return 0; | 1227 | return false; |
1228 | 1228 | ||
1229 | /* Changed combination key and there's no previous one */ | 1229 | /* Changed combination key and there's no previous one */ |
1230 | if (key_type == HCI_LK_CHANGED_COMBINATION && old_key_type == 0xff) | 1230 | if (key_type == HCI_LK_CHANGED_COMBINATION && old_key_type == 0xff) |
1231 | return 0; | 1231 | return false; |
1232 | 1232 | ||
1233 | /* Security mode 3 case */ | 1233 | /* Security mode 3 case */ |
1234 | if (!conn) | 1234 | if (!conn) |
1235 | return 1; | 1235 | return true; |
1236 | 1236 | ||
1237 | /* Neither local nor remote side had no-bonding as requirement */ | 1237 | /* Neither local nor remote side had no-bonding as requirement */ |
1238 | if (conn->auth_type > 0x01 && conn->remote_auth > 0x01) | 1238 | if (conn->auth_type > 0x01 && conn->remote_auth > 0x01) |
1239 | return 1; | 1239 | return true; |
1240 | 1240 | ||
1241 | /* Local side had dedicated bonding as requirement */ | 1241 | /* Local side had dedicated bonding as requirement */ |
1242 | if (conn->auth_type == 0x02 || conn->auth_type == 0x03) | 1242 | if (conn->auth_type == 0x02 || conn->auth_type == 0x03) |
1243 | return 1; | 1243 | return true; |
1244 | 1244 | ||
1245 | /* Remote side had dedicated bonding as requirement */ | 1245 | /* Remote side had dedicated bonding as requirement */ |
1246 | if (conn->remote_auth == 0x02 || conn->remote_auth == 0x03) | 1246 | if (conn->remote_auth == 0x02 || conn->remote_auth == 0x03) |
1247 | return 1; | 1247 | return true; |
1248 | 1248 | ||
1249 | /* If none of the above criteria match, then don't store the key | 1249 | /* If none of the above criteria match, then don't store the key |
1250 | * persistently */ | 1250 | * persistently */ |
1251 | return 0; | 1251 | return false; |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]) | 1254 | struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]) |
@@ -1285,7 +1285,8 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, | |||
1285 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len) | 1285 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len) |
1286 | { | 1286 | { |
1287 | struct link_key *key, *old_key; | 1287 | struct link_key *key, *old_key; |
1288 | u8 old_key_type, persistent; | 1288 | u8 old_key_type; |
1289 | bool persistent; | ||
1289 | 1290 | ||
1290 | old_key = hci_find_link_key(hdev, bdaddr); | 1291 | old_key = hci_find_link_key(hdev, bdaddr); |
1291 | if (old_key) { | 1292 | if (old_key) { |
@@ -1328,10 +1329,8 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, | |||
1328 | 1329 | ||
1329 | mgmt_new_link_key(hdev, key, persistent); | 1330 | mgmt_new_link_key(hdev, key, persistent); |
1330 | 1331 | ||
1331 | if (!persistent) { | 1332 | if (conn) |
1332 | list_del(&key->list); | 1333 | conn->flush_key = !persistent; |
1333 | kfree(key); | ||
1334 | } | ||
1335 | 1334 | ||
1336 | return 0; | 1335 | return 0; |
1337 | } | 1336 | } |