diff options
author | Andre Guedes <andre.guedes@openbossa.org> | 2013-03-08 09:20:13 -0500 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-03-09 15:10:13 -0500 |
commit | bc4445c72cb5d1ed5af80c73e60214ab5ebd8e55 (patch) | |
tree | 9b6c9c535389a069b6b6ded72f797c77559ad81d /net/bluetooth/hci_core.c | |
parent | d865b0070485dfbb0611c5dc07fff21c440858a5 (diff) |
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.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3fc699db8fb5..5c6439847286 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, | |||
95 | 95 | ||
96 | hdev->req_status = HCI_REQ_PEND; | 96 | hdev->req_status = HCI_REQ_PEND; |
97 | 97 | ||
98 | add_wait_queue(&hdev->req_wait_q, &wait); | ||
99 | set_current_state(TASK_INTERRUPTIBLE); | ||
100 | |||
101 | func(&req, opt); | 98 | func(&req, opt); |
102 | 99 | ||
103 | err = hci_req_run(&req, hci_req_sync_complete); | 100 | err = hci_req_run(&req, hci_req_sync_complete); |
104 | if (err < 0) { | 101 | if (err < 0) { |
105 | hdev->req_status = 0; | 102 | hdev->req_status = 0; |
106 | remove_wait_queue(&hdev->req_wait_q, &wait); | ||
107 | /* req_run will fail if the request did not add any | 103 | /* req_run will fail if the request did not add any |
108 | * commands to the queue, something that can happen when | 104 | * commands to the queue, something that can happen when |
109 | * a request with conditionals doesn't trigger any | 105 | * a request with conditionals doesn't trigger any |
@@ -113,6 +109,9 @@ static int __hci_req_sync(struct hci_dev *hdev, | |||
113 | return 0; | 109 | return 0; |
114 | } | 110 | } |
115 | 111 | ||
112 | add_wait_queue(&hdev->req_wait_q, &wait); | ||
113 | set_current_state(TASK_INTERRUPTIBLE); | ||
114 | |||
116 | schedule_timeout(timeout); | 115 | schedule_timeout(timeout); |
117 | 116 | ||
118 | remove_wait_queue(&hdev->req_wait_q, &wait); | 117 | remove_wait_queue(&hdev->req_wait_q, &wait); |