Bluetooth: Handle Inquiry Cancel error after Inquiry Complete
authorSonny Sasaka <sonnysasaka@chromium.org>
Wed, 6 May 2020 19:55:03 +0000 (12:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 18:40:13 +0000 (20:40 +0200)
commit7f8a294b5707fb8a6769125f3366e1f38ae7bcec
tree739e55c5df99d2748cabf781fa7efd4e83ded5dd
parent2eee83e8d1836bda9186c03976cc67e817505b0a
Bluetooth: Handle Inquiry Cancel error after Inquiry Complete

[ Upstream commit adf1d6926444029396861413aba8a0f2a805742a ]

After sending Inquiry Cancel command to the controller, it is possible
that Inquiry Complete event comes before Inquiry Cancel command complete
event. In this case the Inquiry Cancel command will have status of
Command Disallowed since there is no Inquiry session to be cancelled.
This case should not be treated as error, otherwise we can reach an
inconsistent state.

Example of a btmon trace when this happened:

< HCI Command: Inquiry Cancel (0x01|0x0002) plen 0
> HCI Event: Inquiry Complete (0x01) plen 1
        Status: Success (0x00)
> HCI Event: Command Complete (0x0e) plen 4
      Inquiry Cancel (0x01|0x0002) ncmd 1
        Status: Command Disallowed (0x0c)

Signed-off-by: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/hci_event.c