Bluetooth: Fix SMP debug key handling
authorJohan Hedberg <johan.hedberg@intel.com>
Wed, 3 Dec 2014 10:43:39 +0000 (12:43 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 3 Dec 2014 15:51:22 +0000 (16:51 +0100)
We need to keep debug keys around at least until the point that they are
used - otherwise e.g. slave role behavior wouldn't work as there'd be no
key to be looked up. The correct behavior should therefore be to return
any stored keys but when we clean up the SMP context to remove the key
from the hdev list if keeping debug keys around hasn't been requestsed.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_core.c
net/bluetooth/smp.c

index c8123f0..f001856 100644 (file)
@@ -3246,15 +3246,7 @@ struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
                if (addr_type != k->bdaddr_type || bacmp(bdaddr, &k->bdaddr))
                        continue;
 
-               if (smp_ltk_is_sc(k)) {
-                       if (k->type == SMP_LTK_P256_DEBUG &&
-                           !test_bit(HCI_KEEP_DEBUG_KEYS, &hdev->dev_flags))
-                               continue;
-                       rcu_read_unlock();
-                       return k;
-               }
-
-               if (ltk_role(k->type) == role) {
+               if (smp_ltk_is_sc(k) || ltk_role(k->type) == role) {
                        rcu_read_unlock();
                        return k;
                }
Simple merge