OSDN Git Service

Merge android-4.4.185 (14e1196) into msm-4.4
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / net / bluetooth / hci_conn.c
index ccddf34..211c259 100644 (file)
@@ -1177,14 +1177,6 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
            !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
                return 0;
 
-       /* The minimum encryption key size needs to be enforced by the
-        * host stack before establishing any L2CAP connections. The
-        * specification in theory allows a minimum of 1, but to align
-        * BR/EDR and LE transports, a minimum of 7 is chosen.
-        */
-       if (conn->enc_key_size < HCI_MIN_ENC_KEY_SIZE)
-               return 0;
-
        return 1;
 }
 
@@ -1301,8 +1293,16 @@ auth:
                return 0;
 
 encrypt:
-       if (test_bit(HCI_CONN_ENCRYPT, &conn->flags))
+       if (test_bit(HCI_CONN_ENCRYPT, &conn->flags)) {
+               /* Ensure that the encryption key size has been read,
+                * otherwise stall the upper layer responses.
+                */
+               if (!conn->enc_key_size)
+                       return 0;
+
+               /* Nothing else needed, all requirements are met */
                return 1;
+       }
 
        hci_conn_encrypt(conn);
        return 0;