summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorJohan Hedberg2013-03-15 23:06:59 +0100
committerGustavo Padovan2013-03-18 18:02:03 +0100
commit35b973c9dd6d518491b251ac777d767d7820aa37 (patch)
treec2142780fc8b1cd371953682aceabf5ede2ff555 /net/bluetooth/hci_core.c
parentBluetooth: Clear non-persistent flags when closing HCI device (diff)
downloadkernel-qcow2-linux-35b973c9dd6d518491b251ac777d767d7820aa37.tar.gz
kernel-qcow2-linux-35b973c9dd6d518491b251ac777d767d7820aa37.tar.xz
kernel-qcow2-linux-35b973c9dd6d518491b251ac777d767d7820aa37.zip
Bluetooth: Fix clearing flags on power off before notifying mgmt
When powering off the device the hdev->flags and hdev->dev_flags need to be cleared before calling mgmt_powered(). If this is not done the resulting events sent to user space may contain incorrect values. Note that the HCI_AUTO_OFF flag accessed right after this is part of the persistent flags, so it's unchanged by the hdev->dev_flags reset. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 059bbae534d1..9e87a91562a6 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1130,6 +1130,10 @@ static int hci_dev_do_close(struct hci_dev *hdev)
* and no tasks are scheduled. */
hdev->close(hdev);
+ /* Clear flags */
+ hdev->flags = 0;
+ hdev->dev_flags &= ~HCI_PERSISTENT_MASK;
+
if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags) &&
mgmt_valid_hdev(hdev)) {
hci_dev_lock(hdev);
@@ -1137,10 +1141,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
hci_dev_unlock(hdev);
}
- /* Clear flags */
- hdev->flags = 0;
- hdev->dev_flags &= ~HCI_PERSISTENT_MASK;
-
/* Controller radio is available but is currently powered down */
hdev->amp_status = 0;