Bluetooth: MGMT: Fix not generating command complete for MGMT_OP_DISCONNECT
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 26 Aug 2024 20:14:04 +0000 (16:14 -0400)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 30 Aug 2024 21:56:34 +0000 (17:56 -0400)
commit227a0cdf4a028a73dc256d0f5144b4808d718893
tree27f98b97e665b6b2927c53abe655a661305c0b71
parentc898f6d7b093bd71e66569cd6797c87d4056f44b
Bluetooth: MGMT: Fix not generating command complete for MGMT_OP_DISCONNECT

MGMT_OP_DISCONNECT can be called while mgmt_device_connected has not
been called yet, which will cause the connection procedure to be
aborted, so mgmt_device_disconnected shall still respond with command
complete to MGMT_OP_DISCONNECT and just not emit
MGMT_EV_DEVICE_DISCONNECTED since MGMT_EV_DEVICE_CONNECTED was never
sent.

To fix this MGMT_OP_DISCONNECT is changed to work similarly to other
command which do use hci_cmd_sync_queue and then use hci_conn_abort to
disconnect and returns the result, in order for hci_conn_abort to be
used from hci_cmd_sync context it now uses hci_cmd_sync_run_once.

Link: https://github.com/bluez/bluez/issues/932
Fixes: 12d4a3b2ccb3 ("Bluetooth: Move check for MGMT_CONNECTED flag into mgmt.c")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_conn.c
net/bluetooth/mgmt.c