Bluetooth: Reorder HCI user channel socket release
authorLoic Poulain <loic.poulain@intel.com>
Thu, 21 May 2015 14:46:41 +0000 (16:46 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 6 Jun 2015 18:49:04 +0000 (20:49 +0200)
The hci close method needs to know if we are in user channel context.
Only add the index to mgmt once close is performed.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_sock.c

index 5b14dcafcd084103eee55be0929b180b99e7bb94..9467545e5c97c408c9be213ab9e4c9996f05918c 100644 (file)
@@ -503,9 +503,9 @@ static int hci_sock_release(struct socket *sock)
 
        if (hdev) {
                if (hci_pi(sk)->channel == HCI_CHANNEL_USER) {
-                       mgmt_index_added(hdev);
-                       hci_dev_clear_flag(hdev, HCI_USER_CHANNEL);
                        hci_dev_close(hdev->id);
+                       hci_dev_clear_flag(hdev, HCI_USER_CHANNEL);
+                       mgmt_index_added(hdev);
                }
 
                atomic_dec(&hdev->promisc);