Skip to content

Commit 1e91c29

Browse files
Johan Hedbergholtmann
authored andcommitted
Bluetooth: Use hci_disconnect for immediate disconnection from SMP
Relying on the l2cap_conn_del procedure (triggered through the l2cap_conn_shutdown API) to get the connection disconnected is not reliable as it depends on all users releasing (through hci_conn_drop) and that there's at least one user (so hci_conn_drop is called at least one time). A much simpler and more reliable solution is to call hci_disconnect() directly from the SMP code when we want to disconnect. One side-effect this has is that it prevents any SMP Failure PDU from being sent before the disconnection, however neither one of the scenarios where l2cap_conn_shutdown was used really requires this. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent e31fb86 commit 1e91c29

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/bluetooth/smp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ static void smp_timeout(struct work_struct *work)
829829

830830
BT_DBG("conn %p", conn);
831831

832-
l2cap_conn_shutdown(conn, ETIMEDOUT);
832+
hci_disconnect(conn->hcon, HCI_ERROR_REMOTE_USER_TERM);
833833
}
834834

835835
static struct smp_chan *smp_chan_create(struct l2cap_conn *conn)
@@ -1569,7 +1569,7 @@ static int smp_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
15691569
if (smp)
15701570
cancel_delayed_work_sync(&smp->security_timer);
15711571

1572-
l2cap_conn_shutdown(chan->conn, -err);
1572+
hci_disconnect(chan->conn->hcon, HCI_ERROR_AUTH_FAILURE);
15731573
}
15741574

15751575
return err;

0 commit comments

Comments
 (0)