FROMGIT: Bluetooth: Check inquiry status before sending one

There is a possibility where HCI_INQUIRY flag is set but we still
send HCI_OP_INQUIRY anyway.

Such a case can be reproduced by connecting to an LE device while
active scanning. When the device is discovered, we initiate a
connection, stop LE Scan, and send Discovery MGMT with status
disabled, but we don't cancel the inquiry.

BUG=b:180148986
TEST=Do these steps.
(1) Start active scan
(2) Within 10 seconds, scan and establish a successful connection to
    a before unpaired LE device. If 10 seconds has passed, we are
    not 'actively' scanning anymore, so remove the device and retry.
(3) Verify no "Command Disallowed" in btsnoop log.

Signed-off-by: Archie Pusaka <apusaka@chromium.org>
Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
(cherry picked from commit 06752d1678b49ac471f11950ebd6d29541828bba git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master)
Change-Id: I26d172ded4e4ac8ad334516a8d196539777fba2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2810037
Reviewed-by: Sean Paul <seanpaul@chromium.org>
1 file changed