]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/bluetooth/smp.c
Bluetooth: Fix use-after-free bug in SMP
[karo-tx-linux.git] / net / bluetooth / smp.c
index 901a616c8083e22f5163f8bbd1613b1529c63519..98ffc1b6a6fad9b3ac8f754077aa3472eb60efb1 100644 (file)
@@ -267,10 +267,10 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send)
        mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type,
                         hcon->dst_type, reason);
 
-       if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags)) {
-               cancel_delayed_work_sync(&conn->security_timer);
+       cancel_delayed_work_sync(&conn->security_timer);
+
+       if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags))
                smp_chan_destroy(conn);
-       }
 }
 
 #define JUST_WORKS     0x00