@@ -42,10 +42,9 @@
/* Handle HCI Event packets */
-static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
+static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb,
+ u8 status)
{
- __u8 status = *((__u8 *) skb->data);
-
BT_DBG("%s status 0x%2.2x", hdev->name, status);
if (status)
@@ -3233,7 +3232,19 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
switch (*opcode) {
case HCI_OP_INQUIRY_CANCEL:
- hci_cc_inquiry_cancel(hdev, skb);
+ /* It is possible that we receive Inquiry Complete event right
+ * before we receive Inquiry Cancel Command Complete event, in
+ * which case the latter event should have status of Command
+ * Disallowed (0x0c). This should not be treated as error, since
+ * we actually achieve what Inquiry Cancel wants to achieve,
+ * which is to end the last Inquiry session.
+ */
+ if (*status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) {
+ BT_DBG("Ignoring error of HCI Inquiry Cancel command");
+ *status = 0;
+ }
+
+ hci_cc_inquiry_cancel(hdev, skb, *status);
break;
case HCI_OP_PERIODIC_INQ: