From: Johan Hedberg Date: Tue, 5 Mar 2013 18:37:42 +0000 (+0200) Subject: Bluetooth: Fix __hci_req_sync() handling of empty requests X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=53cce22dc795e73fb48205e3f584f63f4c71c90c;p=openwrt%2Fstaging%2Fblogic.git Bluetooth: Fix __hci_req_sync() handling of empty requests 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 Acked-by: Marcel Holtmann Signed-off-by: Gustavo Padovan --- diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 551df8a6f983..9369e010c90e 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -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);