Bluetooth: Ignore incoming data after initiating disconnection
authorJohan Hedberg <johan.hedberg@intel.com>
Sun, 17 Aug 2014 21:41:44 +0000 (00:41 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 8 Sep 2014 17:07:53 +0000 (19:07 +0200)
When hci_chan_del is called the disconnection routines get scheduled
through a workqueue. If there's any incoming ACL data before the
routines get executed there's a chance that a new hci_chan is created
and the disconnection never happens. This patch adds a new hci_conn flag
to indicate that we're in the process of driving the connection down. We
set the flag in hci_chan_del and check for it in hci_chan_create so that
no new channels are created for the same connection.

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

index 18c24f6fce6c07598c2e77a60a3fef760d45e25f..dbe73642c54cb7b6381f108ab1f743574b2da16e 100644 (file)
@@ -553,6 +553,7 @@ enum {
        HCI_CONN_FIPS,
        HCI_CONN_STK_ENCRYPT,
        HCI_CONN_AUTH_INITIATOR,
+       HCI_CONN_DROP,
 };
 
 static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
index cb04a4e3c82965518840473b0515f0719f1c4bda..aaa7e388d026f2d192a7b20b895f2ec690dc34e7 100644 (file)
@@ -1291,6 +1291,11 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn)
 
        BT_DBG("%s hcon %p", hdev->name, conn);
 
+       if (test_bit(HCI_CONN_DROP, &conn->flags)) {
+               BT_DBG("Refusing to create new hci_chan");
+               return NULL;
+       }
+
        chan = kzalloc(sizeof(*chan), GFP_KERNEL);
        if (!chan)
                return NULL;
@@ -1318,6 +1323,7 @@ void hci_chan_del(struct hci_chan *chan)
 
        /* Force the connection to be immediately dropped */
        conn->disc_timeout = 0;
+       set_bit(HCI_CONN_DROP, &conn->flags);
 
        hci_conn_drop(conn);
        hci_conn_put(conn);
This page took 0.031289 seconds and 5 git commands to generate.