Bluetooth: Fix __hci_req_sync() handling of empty requests
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / bluetooth / hci_core.c
index 551df8a6f983ef08df1be23db96b7d9a421d8a04..9369e010c90ee0e476c75785c2a5fe30f103369e 100644 (file)
@@ -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);