Merge tag 'staging-4.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[firefly-linux-kernel-4.4.55.git] / net / bluetooth / smp.c
index 3d0f7d2a06162248a1e6589fe3d59022f9dded0d..0510a577a7b58ef7dfbace4a68d712a3b8239891 100644 (file)
@@ -2311,8 +2311,6 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
        if (!conn)
                return 1;
 
-       chan = conn->smp;
-
        if (!hci_dev_test_flag(hcon->hdev, HCI_LE_ENABLED))
                return 1;
 
@@ -2326,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 */