Return-Path: From: Johan Hedberg To: linux-bluetooth@vger.kernel.org Subject: [PATCH 01/14] Bluetooth: Fix __hci_request() handling of empty requests Date: Fri, 22 Feb 2013 15:12:26 +0200 Message-Id: <1361538759-13558-2-git-send-email-johan.hedberg@gmail.com> In-Reply-To: <1361538759-13558-1-git-send-email-johan.hedberg@gmail.com> References: <1361538759-13558-1-git-send-email-johan.hedberg@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: From: Johan Hedberg If a request callback doesn't send any commands __hci_request() 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 --- net/bluetooth/hci_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index aeb2b26..fd6921f 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -122,6 +122,14 @@ static int __hci_request(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); -- 1.7.10.4