Skip to content

Commit

Permalink
Bluetooth: Delay check for conn->smp in smp_conn_security()
Browse files Browse the repository at this point in the history
There are several actions that smp_conn_security() might make that do
not require a valid SMP context (conn->smp pointer). One of these
actions is to encrypt the link with an existing LTK. If the SMP
context wasn't initialized properly we should still allow the
independent actions to be done, i.e. the check for the context should
only be done at the last possible moment.

Reported-by: Chuck Ebbert <cebbert.lkml@gmail.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: stable@vger.kernel.org # 4.0+
  • Loading branch information
jhedberg authored and holtmann committed Sep 17, 2015
1 parent 20471ed commit d8949aa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions net/bluetooth/smp.c
Expand Up @@ -2311,12 +2311,6 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
if (!conn)
return 1;

chan = conn->smp;
if (!chan) {
BT_ERR("SMP security requested but not available");
return 1;
}

if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED))
return 1;

Expand All @@ -2330,6 +2324,12 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
if (smp_ltk_encrypt(conn, hcon->pending_sec_level))
return 0;

chan = conn->smp;
if (!chan) {
BT_ERR("SMP security requested but not available");
return 1;
}

l2cap_chan_lock(chan);

/* If SMP is already in progress ignore this request */
Expand Down

0 comments on commit d8949aa

Please sign in to comment.