Skip to content

Commit

Permalink
Bluetooth: Fix __hci_req_sync() handling of empty requests
Browse files Browse the repository at this point in the history
If a request callback doesn't send any commands __hci_req_sync() should
fail imediately instead of waiting for the inevitable timeout to occur.
This is particularly important once we start creating requests with
conditional command sending which can potentially result in no commands
being sent at all.

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>
  • Loading branch information
Johan Hedberg authored and Gustavo Padovan committed Mar 8, 2013
1 parent 01178cd commit 53cce22
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ static int __hci_req_sync(struct hci_dev *hdev,
set_current_state(TASK_INTERRUPTIBLE);

req(hdev, opt);

/* If the request didn't send any commands return immediately */
if (skb_queue_empty(&hdev->cmd_q) && atomic_read(&hdev->cmd_cnt)) {
hdev->req_status = 0;
remove_wait_queue(&hdev->req_wait_q, &wait);
return err;
}

schedule_timeout(timeout);

remove_wait_queue(&hdev->req_wait_q, &wait);
Expand Down

0 comments on commit 53cce22

Please sign in to comment.