summaryrefslogtreecommitdiff
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2013-03-08 14:20:13 (GMT)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-03-09 20:10:13 (GMT)
commitbc4445c72cb5d1ed5af80c73e60214ab5ebd8e55 (patch)
tree9b6c9c535389a069b6b6ded72f797c77559ad81d /net/bluetooth/hci_core.c
parentd865b0070485dfbb0611c5dc07fff21c440858a5 (diff)
downloadlinux-bc4445c72cb5d1ed5af80c73e60214ab5ebd8e55.tar.xz
Bluetooth: Fix __hci_req_sync
If hci_req_run returns error, we erroneously leave the current process in TASK_INTERRUPTABLE state. If we leave the process in TASK_INTERRUPTABLE and it is preempted, this process will never be scheduled again. This patch fixes this issue by moving the preparation for scheduling (add to waitqueue and set process state) to just after the hci_req_run call. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Acked-by: Johan Hedberg <johan.hedberg@intel.com> 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.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 3fc699d..5c64398 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -95,15 +95,11 @@ static int __hci_req_sync(struct hci_dev *hdev,
hdev->req_status = HCI_REQ_PEND;
- add_wait_queue(&hdev->req_wait_q, &wait);
- set_current_state(TASK_INTERRUPTIBLE);
-
func(&req, opt);
err = hci_req_run(&req, hci_req_sync_complete);
if (err < 0) {
hdev->req_status = 0;
- remove_wait_queue(&hdev->req_wait_q, &wait);
/* req_run will fail if the request did not add any
* commands to the queue, something that can happen when
* a request with conditionals doesn't trigger any
@@ -113,6 +109,9 @@ static int __hci_req_sync(struct hci_dev *hdev,
return 0;
}
+ add_wait_queue(&hdev->req_wait_q, &wait);
+ set_current_state(TASK_INTERRUPTIBLE);
+
schedule_timeout(timeout);
remove_wait_queue(&hdev->req_wait_q, &wait);