Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetoot...
authorJohn W. Linville <linville@tuxdriver.com>
Fri, 27 Apr 2012 19:16:43 +0000 (15:16 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 27 Apr 2012 19:16:43 +0000 (15:16 -0400)
1  2 
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c

diff --combined net/bluetooth/hci_core.c
@@@ -45,6 -45,7 +45,6 @@@
  #include <linux/crypto.h>
  #include <net/sock.h>
  
 -#include <asm/system.h>
  #include <linux/uaccess.h>
  #include <asm/unaligned.h>
  
@@@ -1215,40 -1216,40 +1215,40 @@@ struct link_key *hci_find_link_key(stru
        return NULL;
  }
  
- static int hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn,
+ static bool hci_persistent_key(struct hci_dev *hdev, struct hci_conn *conn,
                                                u8 key_type, u8 old_key_type)
  {
        /* Legacy key */
        if (key_type < 0x03)
-               return 1;
+               return true;
  
        /* Debug keys are insecure so don't store them persistently */
        if (key_type == HCI_LK_DEBUG_COMBINATION)
-               return 0;
+               return false;
  
        /* Changed combination key and there's no previous one */
        if (key_type == HCI_LK_CHANGED_COMBINATION && old_key_type == 0xff)
-               return 0;
+               return false;
  
        /* Security mode 3 case */
        if (!conn)
-               return 1;
+               return true;
  
        /* Neither local nor remote side had no-bonding as requirement */
        if (conn->auth_type > 0x01 && conn->remote_auth > 0x01)
-               return 1;
+               return true;
  
        /* Local side had dedicated bonding as requirement */
        if (conn->auth_type == 0x02 || conn->auth_type == 0x03)
-               return 1;
+               return true;
  
        /* Remote side had dedicated bonding as requirement */
        if (conn->remote_auth == 0x02 || conn->remote_auth == 0x03)
-               return 1;
+               return true;
  
        /* If none of the above criteria match, then don't store the key
         * persistently */
-       return 0;
+       return false;
  }
  
  struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8])
@@@ -1285,7 -1286,8 +1285,8 @@@ int hci_add_link_key(struct hci_dev *hd
                     bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len)
  {
        struct link_key *key, *old_key;
-       u8 old_key_type, persistent;
+       u8 old_key_type;
+       bool persistent;
  
        old_key = hci_find_link_key(hdev, bdaddr);
        if (old_key) {
  
        mgmt_new_link_key(hdev, key, persistent);
  
-       if (!persistent) {
-               list_del(&key->list);
-               kfree(key);
-       }
+       if (conn)
+               conn->flush_key = !persistent;
  
        return 0;
  }
@@@ -37,6 -37,7 +37,6 @@@
  #include <linux/interrupt.h>
  #include <net/sock.h>
  
 -#include <asm/system.h>
  #include <linux/uaccess.h>
  #include <asm/unaligned.h>
  
@@@ -1901,6 -1902,8 +1901,8 @@@ static inline void hci_disconn_complete
        }
  
        if (ev->status == 0) {
+               if (conn->type == ACL_LINK && conn->flush_key)
+                       hci_remove_link_key(hdev, &conn->dst);
                hci_proto_disconn_cfm(conn, ev->reason);
                hci_conn_del(conn);
        }
@@@ -2311,6 -2314,7 +2313,7 @@@ static inline void hci_cmd_complete_evt
  
        case HCI_OP_USER_PASSKEY_NEG_REPLY:
                hci_cc_user_passkey_neg_reply(hdev, skb);
+               break;
  
        case HCI_OP_LE_SET_SCAN_PARAM:
                hci_cc_le_set_scan_param(hdev, skb);